stil4m / elm-analyse Goto Github PK
View Code? Open in Web Editor NEWA tool that allows you to analyse your Elm code, identify deficiencies and apply best practices.
Home Page: https://stil4m.github.io/elm-analyse/
License: MIT License
A tool that allows you to analyse your Elm code, identify deficiencies and apply best practices.
Home Page: https://stil4m.github.io/elm-analyse/
License: MIT License
I wanted to try out elm-analyse, but unfortunately I have trouble with installation. It seems that the script can't find elm-format-download (whatever that thing is...)
I'm on Linux Mint 18
node 7.2.1
elm 18.0
elm-format 0.5.2-alpha
This is the error I get trying to run yarn add
error /home/jacek/node_modules/elm-analyse: Command failed.
Exit code: 127
Command: sh
Arguments: -c ./node_modules/.bin/elm-format-download -t ./node_modules/.bin
Directory: /home/jacek/node_modules/elm-analyse
Output:
sh: 1: ./node_modules/.bin/elm-format-download: not found
and here is error part from npm-debug.log when I run (sudo) npm add -g elm-analyse
38875 verbose stack Error: [email protected] postinstall: `elm-format-download -t ./node_modules/.bin`
38875 verbose stack spawn ENOENT
38875 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:33:16)
38875 verbose stack at emitTwo (events.js:106:13)
38875 verbose stack at ChildProcess.emit (events.js:191:7)
38875 verbose stack at maybeClose (internal/child_process.js:885:16)
38875 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
38876 verbose pkgid [email protected]
38877 verbose cwd /home/jacek/bin
38878 error Linux 4.4.0-21-generic
38879 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "elm-analyse"
38880 error node v7.2.1
38881 error npm v3.10.10
38882 error file sh
38883 error code ELIFECYCLE
38884 error errno ENOENT
38885 error syscall spawn
38886 error [email protected] postinstall: `elm-format-download -t ./node_modules/.bin`
38886 error spawn ENOENT
38887 error Failed at the [email protected] postinstall script 'elm-format-download -t ./node_modules/.bin'.
38887 error Make sure you have the latest version of node.js and npm installed.
38887 error If you do, this is most likely a problem with the elm-analyse package,
38887 error not with npm itself.
38887 error Tell the author that this fails on your system:
38887 error elm-format-download -t ./node_modules/.bin
38887 error You can get information on how to open an issue for this project with:
38887 error npm bugs elm-analyse
38887 error Or if that isn't available, you can get their info via:
38887 error npm owner ls elm-analyse
38887 error There is likely additional logging output above.
Add max length configuration for LineLengthExceeded
Right now elm-analyse always exits with status 0
.
This makes it more difficult to run it in a CI setting where we want to mark a build as unstable for certain conditions.
It would be nice if the exit code was only 0
for runs without encountering any issues.
At a minimum it should be non-zero when encountering issues. Nice to have would be a configurable threshold for "unstable"/"failed". We could then exit with status code 1
if any issues were encountered and status code 2
if the threshold it exceeded.
Currently (,,)
is marked as unnecessary binary prefix operator. This is false of course while the following block is a function instead of value
(,,) foo bar
For example with the following source-directories:
"source-directories" : [
"."
]
And you have the following file structure:
elm-package.json
Main.elm
tests/MainTest.elm
tests/elm-package.json
Then tests/MainTest.elm
should be ignored when analysing the elm-package.json
in the root.
It would be nice to detect cyclic dependencies between packages
This is a tiny nitpick, but it seems that unnecessary params around a number/expression/constant with negation sign are not reported.
Reporting unnecessary params:
(toFloat 5) / 2
(toFloat (3 + 3)) / 2
(toFloat width) / 2
Same thing here, but not reported:
(toFloat -5) / 2
(toFloat -(3 + 3)) / 2
(toFloat -width) / 2
When a fix is located on the last line of the file, the fix fails.
There is no highlighting on the first line. This especially happens for the Exposing all in file
message.
Implementation issue of #5
This is required to make sure that the frontend code does not mismatch the backend code (especially for decoders).
Thanks to @mbuscemi for reporting this via slack
I commented out some attributes and ran into parsing error on this syntax
view =
div [{- I commented some stuff out -}] []
Could not load file "View.elm" due to: Could not continue parsing on location (21,7)
Looks like this only happens for empty list, because lists like [1, 2 {- comment -}]
and [{- comment -} 1, 2]
work fine (inline comment is OK too)
Use of Core's Array
package should checked. This is because of issue number 649 in elm-lang/core
.
let
are commonly used to hold intermediate values that are used (multiple times) in other expressions in the let
binding.
There is no reason to have functions in there, extracting these to top-levels would be a better choice. Encapsulation can be achieved by not exposing that extracted function or by creating a whole new module.
Currently documentation comments are interpreted as just comments. In the post processing phase, these should be attached to the functions.
It may be confusing that elm-analyse
loads the dependencies on the first run. Better logging of the stage of the analysis process would mitigate this.
It would be nice to be able to exclude certain paths. E.g. I would like to exclude the "elm-stuff" directory as well as our "vendor" directory as this includes code that is not 100% under our control.
Ideally this could be done via the elm-analyse.json
. E.g.:
{
"checks": {
"LineLengthExceeded" : false
},
"excludedPaths": [ "elm-stuff", "vendor" ]
}
List.concat
when concatenating only fixed size lists.N
fields. (#24)\_ -> b
to always b
and \x -> List.map f x
to List.map f
)++
.elm-lang/*
or elm-community/*
.Sort messages on file and range in UI and console
Add ESLint to verify style of code in PRs
When using .
as source-directories
the file gatherer will search the node_modules
folder if present. This of course is not related source code.
This folder should be ignored.
Hi! As discussed on Slack, there should be better messages when parsing fails. Currently, the message is always "expected end of input"
.
elm-analyse --version
or -v
should print the current version to the console.
When loading all files these appear to be cached in elm-stuff/elm-analyse/
and in particular in elm-stuff/elm-analyse/_shas
. This duplicates the source files, which confuses the popular Atom plugin elmjutsu. Maybe we can find a way to store the cache outside of the source folder (e.g. in /tmp
or ~/.elm-analyse
).
This issue manifests itself most prominently when also using the hyper click plugin.
Things to do:
--help
command line optionelm-analyse.json
)Unused imported variable Zipper
in file "src/elm/View/Survey.elm" at ((4,35),(4,41))
mbaumann [22:41]
@stil4m: i am using your tool on my most recent project and i am trying to get all the messages out, but I am having this case where I am not sure how to handle or if it's an issue:
i tried many variants. my last import looked like this:
import List.Zipper exposing (Zipper(Zipper))
with a statement like this:
let (Zipper prev cur next) = model.thing
in ...
gives me:
Unused imported variable `Zipper` in file "src/elm/View/Survey.elm" at ((4,35),(4,41))
Use of Regex.regex as a non static function (runtime error abound)
The parens in the following example are not detected as unnecessary:
x =
[ (y 1)
]
Of course this is the case.
(node:8144) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Trying to send an unexpected type of value through port onFileContentWithShas
:
Expecting a String at _[0][0] but instead got: null
foo =
(f a b)
The program crashes when source-directories
refer to a folder that not exists.
Should the program crash, or should it just ignore the folder with a warning?
For example when N = 2
then the following is allowed
type alias X
{ name : String, age : Int }
But this isnt
type alias X
{ name : String, age : Int, language : String }
This should be formatted on multiple lines:
type alias X
{ name : String
, age : Int
, language : String
}
Unused imported operator doesn't trigger a warning
import List.Extra exposing ((!!))
This leads to the AST that is decoded to contain Nothing
on certain nodes, while the whole decoding should fail.
Work on a graph analyser has been started in #39.
The next steps will be:
Plenty of terminals allow opening the browser when cmd-click'ing (or equivalent) on something that looks like a url. Simply printing something like Listening on http://localhost:3000
would be great :)
Program fails when dependency is not installed. Null value is sent through port
module Main exposing (..)
import X as Y
z a =
case a of
Y.Z ->
1
For example:
{-| Fix me ... -}
-- TODO
The NoUncurriedPrefix
checks if binary operators are used in prefix notation instead of infix notation. For example: (+) 1 2
instead of 1 + 2
.
Sometimes using operator prefix notation is more convenient.
To construct tuples (@manuscrypt):
[ (,) "color" "red" ]
Or for elm-css:
(.) MyClass
[ ...
]
The point is:
Should this check be dropped, become less strict, highly configurable or something else?
Suggestions are welcome :)
Remove TypeArg
from AST.
Add autofixer for unused type alias
Add UnnecessaryPortModule check
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.