style: Always pass a regex match to split#7082
style: Always pass a regex match to split#7082mergify[bot] merged 1 commit intoos-autoinst:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7082 +/- ##
=======================================
Coverage 99.72% 99.72%
=======================================
Files 416 416
Lines 43076 43076
=======================================
Hits 42956 42956
Misses 120 120 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
:( |
okurz
left a comment
There was a problem hiding this comment.
I would be interested how the actual automatic rule enforcement would be configured. I don't see this style as strictly necessary but I favor consistency and adherence to standards. So, you are stating
Can be enforced later by BuiltinFunctions::ProhibitStringySplit or Community::SplitQuotedPattern
but why not enable such rules directly? Where we configure those? ANd you have a URL to an external reference that states "this is a good standard"?
I can think of two ways. The current content of https://github.com/os-autoinst/openQA/blob/master/external/os-autoinst-common/.perlcriticrc is: We can either I think b) would make most sense for now as we add rules. If we use the majority of rules, then exclude might make more sense, but I doubt it. As I stated in the other PR, I did not directly change .perlcriticrc as part of this PR, because it is a symlink to the Does anything speak against this? Of course if we not enforce it immediately, there might be code added meanwhile that does not adhere to one of the new rules. But my goal is to change most of the lines now, and when we enforce them later, there can be a handful of lines that we have to change, but not 500 like in my first PR.
What we could also do: Temporarily make the
I think the quoting was broken, so I fixed it, so the "but why" was from you.
Perl::Critic was inspired after the book Perl Best Practices from Damian Conway. Who himself also pointed out that the rules in the book are opinionated, and the most important thing is that you find good reasons for or against a rule, but be consistent. |
So would you actually vote for this rule or against it? |
Martchus
left a comment
There was a problem hiding this comment.
Will using a regex be slower?
No. It always uses a regex, just that it accepts it to be passed as a string as well. |
A quoted string works as well for literal strings, but it is inconsistent Can be enforced later by Community::SplitQuotedPattern
A quoted string works as well for literal strings, but it is inconsistent
Can be enforced later by
BuiltinFunctions::ProhibitStringySplitorCommunity::SplitQuotedPatternSee also