seaofvoices / darklua

A command line tool that transforms Lua code
https://darklua.com/
MIT License
78 stars 10 forks source link

Add rule to append text comments #141

Closed jeparlefrancais closed 9 months ago

jeparlefrancais commented 10 months ago

Closes #122

This PR adds a new rule that generates a comment at the start or the end of each file. The rule can be configured to take the comment content from the rule configuration or from a file.

For example, to create a comment from the rule configuration itself:

{
  rule: "append_text_comment",
  text: "comment content",
}

Or to create a comment from a file:

{
  rule: "append_text_comment",
  file: "path/to/file.txt",
}

This rule can be configured to append at the start (default) or the end of each file:

{
  rule: "append_text_comment",
  text: "comment content",
  location: "end", // or default is "start"
}
github-actions[bot] commented 9 months ago

Coverage after merging rule-append-text-comment into main will be

87.20%

Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
src/nodes
   block.rs95.76%100%97.70%95.38%16, 19, 204–206, 241–246, 25–26, 28, 31, 40, 49–50, 52, 55
   identifier.rs93.88%100%90%94.87%63–65
src/nodes/expressions
   parenthese.rs79.55%100%77.27%80.30%100–102, 25–28, 76–78, 99
src/nodes/statements
   assign.rs93.79%100%89.66%94.83%44–46
   function.rs93.20%100%91.43%93.58%123–125, 178–179, 181, 38, 383–385, 39, 405, 41, 418, 441–442, 444
   generic_for.rs96.51%100%90%97.89%
   if_statement.rs82.77%100%78.33%83.90%117, 163, 231–236, 238–240, 242–243, 256–258, 266–269, 27–30, 49–55
   last_statement.rs92.75%100%88.57%94.17%30–31
   local_assign.rs95.64%100%93.10%96.06%121–124, 224, 52–53, 55–56
   local_function.rs93.73%100%91.38%94.29%122–126, 240–242, 272, 285, 311
   numeric_for.rs93.57%100%87.10%95%163–165, 54
   repeat_statement.rs95.70%100%91.30%97.14%
   while_statement.rs93.81%100%86.96%95.95%
src/rules
   append_text_comment.rs49.37%100%62.86%48.29%118–125, 141–154, 160–171, 177–186, 192–201, 207–223, 229–240, 246–253, 259–267, 282–300, 321–328, 331–333, 335–337, 347–348, 350–351, 360–362, 366–368, 37, 370–371, 379, 38, 380, 385–389, 39, 390–393, 40, 406–407, 41, 413–419, 42, 420, 43, 450–455, 462, 475, 483–498, 505–507, 54, 56–59, 67, 69–74, 77–81
   configuration_error.rs64.71%100%83.33%61.64%100, 72–73, 75–77, 79–81, 83–84, 86, 90–99
   mod.rs88.97%100%77.78%90.43%103–105, 109, 119–121, 139–141, 143, 174–176, 260, 301–302, 337–339, 402–404, 64