Repository navigation
Add smell for limitting the number of explicit imports - #1677
Conversation
|
This is especially helpful to contain the number of explicit imports in the codebase where a portion of people use HLS, since HLS by default uses explicit import lists, but lots of explicit imports make the codebase incredibly hard/tedious to modify for people who don't use HLS. |
cd98ab3 to
3723414
Compare
|
Gentle ping @zliu41, @ndmitchell |
zliu41
left a comment
There was a problem hiding this comment.
hints.md should be updated.
| case Map.lookup SmellManyExplicitImports sm of | ||
| Just limit -> | ||
| case ideclImportList decl of | ||
| Just (Exactly, L _ names) | length names > limit -> |
There was a problem hiding this comment.
This is inconsistent: > vs. >= (used by manyImportsHint).
e05d934 to
eb344c2
Compare
|
Smells weren't included in |
eb344c2 to
292ca5b
Compare
| data Summary = Summary | ||
| { sBuiltinRules :: ![BuiltinHint] | ||
| , sLhsRhsRules :: ![HintRule] | ||
| , sSmells :: ![SmellHint] |
There was a problem hiding this comment.
This doesn't seem right. There are two kinds of hints: builtin hints, and configured (lhs-rhs) hints. The smell hints should be part of builtin hints. I don't see why it needs to be added as the third kind.
There was a problem hiding this comment.
I initially included them with the rest, but the setup in the table didn't make sense to me for smells when I looked at it. See below. With the other hints there are neat examples of what the code should look like comparisons, which there aren't for smells.
Including smells in with the other hints
Builtin Smell
| Hint Name | Hint | Severity |
|---|---|---|
| Too many explicit imports |
Example:
import A (x, y)Found: import A ( x, y ) |
Warning |
| Many imports |
Example:
import A; import BFound: import A import B |
Warning |
| Many arg function |
Example:
f :: Int -> Int -> Int f = undefinedFound: f :: Int -> Int -> Int |
Warning |
| Long type list |
Example:
f :: Bool -> Int -> (Int -> Proxy '[a, b])Found: f :: Bool -> Int -> (Int -> Proxy '[a, b]) |
Warning |
| Long function |
Example:
f = do
return z
where
z = do
a
b
Found:
= do a
b
|
Warning |
There was a problem hiding this comment.
It seems the other restricting hints (such as "Avoid restricted extensions") are not part of the summary. Then I think it's OK to not include the smell hints in the summary either.
There was a problem hiding this comment.
Sounds good, I've removed the summary generator edits again.
292ca5b to
79fb3bf
Compare
Fixes #1676.
Does what it says on the tin. Adds a new smell called
many explicit importsthat the user can use to limit the number of explicit imports. Extended both inline (I think that's what these are) and golden tests to include this setting.