elm-analyse icon indicating copy to clipboard operation
elm-analyse copied to clipboard

More checks

Open stil4m opened this issue 9 years ago • 9 comments

  • [x] Exceeded line length
  • [x] Unnecessary List.concat when concatenating only fixed size lists.
  • [x] Record type aliases should be formatted multiline when exceeding N fields. (#24)
  • [ ] Functions where 'too much' happens.
  • [ ] Function should be moved to another module for better encapsulation.
  • [ ] ~~Undocumented function that is exposed by module.~~
  • [ ] Use alias for complex 'thing'. This can be done by inspecting signatures.
  • [ ] ~~Use point free notation where possible (\_ -> b to always b and \x -> List.map f x to List.map f)~~
  • [ ] Determine untested code.
  • [ ] Use multiline string instead of concatenated single line string.
  • [ ] Use list concatenation instead of multiple ++.
  • [ ] Replace function with a function provided by elm-lang/* or elm-community/*.
  • [ ] Magic numbers.
  • [x] Check for unnecessary port modules (#45)

stil4m avatar Feb 22 '17 14:02 stil4m

  • [x] Use of Regex.regex as a non static function (runtime error abound) (#46)
  • [x] Use of Core's Array package (#51)
  • [x] Functions defined in let bindings (#61)

eeue56 avatar Feb 25 '17 20:02 eeue56

  • [ ] use of Random iso Random.Pcg
  • [ ] using current time as a random seed rather than a port

zwilias avatar Feb 26 '17 19:02 zwilias

  • [ ] For functions that have a record as an argument: check if only few (e.g. up to 3/configurable) fields are used and suggest to convert to individual parameters.

One of the "big code-smells" to me are view function that take in the whole model to print e.g. one field. This makes the view function very "potent".

felixLam avatar Mar 06 '17 14:03 felixLam

Use point free notation where possible (\_ -> b) to always b and \x -> List.map f x to List.map f)

While I definitely agree with the second point, I do want to note that the first one seems in direct conflict with the noRedInk elm-style-guide which makes a decent case for \_ -> over always.

There's also the case to be made for eschewing overly point free code in performance critical code (say the inner loops of datastructure manipulation), though that's more relevant for library code as opposed to application code.

Sort of going on a tangent here, but I just realized that you'll be able to differentiate between application bundles and library code in 0.19. Might want to create slightly different presets for those..

zwilias avatar Mar 16 '17 19:03 zwilias

@zwilias Thanks for pointing that out. This kind of information is valuable :).

stil4m avatar Mar 17 '17 08:03 stil4m

https://github.com/stil4m/elm-analyse/issues/89 requests a warning on excessively indented code.

ocharles avatar Jun 22 '17 11:06 ocharles

Another simple metric to check is to count the number of lines in modules and functions. More than once I have found myself trying to understand code from others with files with thousands of lines and functions with hundreds of lines. I like the way how plato shows that info and the complexity of the code.

gabrielperales avatar Sep 23 '17 11:09 gabrielperales

Matthew Buscemi just published an Atom plugin, elm-lens, which (among other things) warns about items that are exposed but not externally referenced.

  • [ ] Exposed item with no external references

This might be a case where applications and libraries should be treated differently.

adeschamps avatar Dec 28 '17 19:12 adeschamps

  • [ ] Internal module used outside of it's related module.

E.g.

I have ModuleName and ModuleName.Internal. I want to be sure that ModuleName.Internal could be imported only by ModuleName. And not by some other modules.

Good

module ModuleName exposing (something)

import ModuleName.Internal

Bad

module OtherModuleName exposing (something)

import ModuleName.Internal

akoppela avatar Feb 28 '18 03:02 akoppela