Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bgohla
Copy link

@bgohla bgohla commented Jul 11, 2024

I add a module Hints.NoCapitalisms that provides a hint to avoid capitalisms in identifiers, with some exceptions. E.g.

module SSL.Foo                                                                                  
class FOO a where
class Foo a where getFOO
data Foo = Bar | BAAZ
getSMS

are discouraged.

The hint has severity Ignored, so it is off by default.

  • Things that might need attention
  • potentially factor out some code.
  • break into several commits.

a:b:c:as -> [a,b,c] : trigrams (c:as)
_otherwise -> []

--- these are copied from Hint.Naming ---
Copy link
Author

@bgohla bgohla Jul 11, 2024

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.

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.

Copy link
Author

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 you internal code base…

Comment on lines +74 to +76
trigrams = \case
a:b:c:as -> [a,b,c] : trigrams (c:as)
_otherwise -> []
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants