ashanbrown / forbidigo

Go linter for forbidding identifiers
Other
123 stars 10 forks source link

Multiple patterns with same message #50

Open aryan26gupta opened 1 month ago

aryan26gupta commented 1 month ago

I am currently using forbidigo in golangci YAML file and I wanted to know if this use-case works or not. I want to have the same message for multiple patterns like:

      - p: 
        - ^fmt\.Print.*$
        - ^log\.Print.*$
        - ^println$
        msg: "Do not commit print statements."

Is this possible in some other way? My code editor shows an error if I try to write it this way.

aryan26gupta commented 1 month ago

Right now I have to write a very complex regex to accomodate multiple patterns 😿

ashanbrown commented 1 month ago

I can suggest a couple of ways to avoid repetition. First, you could combine the regexes using (...|...) notation. Alternatively, you could use yaml anchors and aliases to add the same message to multiple rules.

aryan26gupta commented 1 month ago

I think YAML anchors will be useful, thanks!