-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a hint to avoid capitalisms #1608
base: master
Are you sure you want to change the base?
Conversation
a:b:c:as -> [a,b,c] : trigrams (c:as) | ||
_otherwise -> [] | ||
|
||
--- these are copied from Hint.Naming --- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this PR goes ahead, I would propose factoring out the code below.
{- | ||
Detect uses of capitalisms | ||
|
||
Only allow up to two consecutive capital letters in identifiers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this exception? ID
? Personally I'd prefer uniformity here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be one case.
I'm all for uniformity, by I'm afraid not allowing this exception could make this rule very annoying. Let me do some statistics on our internal code base…
trigrams = \case | ||
a:b:c:as -> [a,b,c] : trigrams (c:as) | ||
_otherwise -> [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't b
also be part of the recursive call?
-a:b:c:as -> [a,b,c] : trigrams (c:as)
+a:b:c:as -> [a,b,c] : trigrams (b:c:as)
Otherwise you're missing triples that exist across the boundary e.g.
hasCapitalism "getFOO" === False -- your example, probably not what you want?
hasCapitalism "geFOO" === True -- should be the same, in any case, right?
I add a module
Hints.NoCapitalisms
that provides a hint to avoid capitalisms in identifiers, with some exceptions. E.g.are discouraged.
The hint has severity
Ignored
, so it is off by default.