Open NobbZ opened 8 years ago
I had the same issue, and when I toggled developer tools (View -> Developer -> Toggle Developer Tools) in Atom, I saw a JS error that looked like this:
TypeError: Cannot read property '1' of null
I noticed that when I ran credo through the command line, I saw two warnings at the top of the output:
A new Hex version is available (0.13.2), please update with `mix local.hex`
A new Credo version is available (0.4.12), please update with `mix deps.update credo`
I updated Hex and Credo, which got rid of these warnings, and also fixed the plugin. Perhaps you have the same issue?
@steveklebanoff I did what you said, but it does not work. I have the latest version of Atom, hex, and credo. Any idea about what it can be?
@devmarco if you run credo on a file through the command line, are there any warning or messages before the output? also -- if you toggle developer tools in Atom, do you see an error?
When I run credo, I can see one "Code Readability" and one "Refactoring opportunities", and on the Atom developer tools, I can see some elixir warnings, but no one error
@devmarco hrm, unfortunately i'm not sure how to debug further. maybe @smeevil has some insight?
Hm, I found the issue!, now it is working well.
The issue was that I had opened my project on Atom by a folder that has more than one projects, and to get it working, you have to open your projet on the root.
So, instead of open your projet like
my_apps
- app_one
_ app_two
you have to open like
app_one
Thanks @steveklebanoff
OK, I found the time to try the tips, but nothing helped.
I even tried to set the path, but it seems not to help.
To make sure it does work in a simple environment, I created a new project.
Adding credo
as a single dependency, putting a function def foo(), do: if !true, do: false, else: true
in the created module.
Running mix credo
manually yields:
Checking 1 source file ...
Refactoring opportunities
┃
┃ [F] ↗ Avoid negated conditions in if-else blocks.
┃ lib/linter_test.ex:2 (LinterTest.foo)
Please report incorrect results: https://github.com/rrrene/credo/issues
Analysis took 0.1 seconds (0.01s to load, 0.1s running checks)
2 mods/funs, found 1 refactoring opportunity.
Showing priority issues: ↑ ↗ → (use `--strict` to show all issues, `--help` for options).
But in atom I do not see anything, even after completely restarting it.
I also tried to directly configure the path to mix, but that doesn't help either. (But setting the path to something that doesn't exist, doesn't show an error as well)
Environment:
After seeing #9, I uncommented the line in question and I can see this message in the logs: Object {stdout: "", stderr: "Der Befehl "C:\Users\NobbZ\project\linter_test\\elixir.bat" ist entweder falsch geschrieben oder konnte nicht gefunden werden.", exitCode: 1}
The line on stderr does translate roughly to "The command "C:\Users\NobbZ\project\linter_test\elixir.bat" is either written wrong or could not be found".
Hi @NobbZ Sorry i cannot be of any help with this. I'm not an Atom user myself, I prefer the IntelliJ range of editors, but made this plugin just for the elixir community :) Also I'm not sure if there are any specific changes needed to make it able to work in a Windows environment. The only things that i noticed in the error message is the double backslash in "C:\Users\NobbZ\project\linter_test\elixir.bat"
That extra slash does not matter!
Please look again carefully. I do not have eny of the elixir related executables in my project folder.
The path is generated from %~dp0
, which is roughly equivalent to readlink -f `dirname $1`
.
So it seems as if the way mix is called from within atom is fundamentally different to the way it is started from a terminal, since in a terminal mix
does work as expected!
Seeing the same problem here. :(
I ran across this issue while trying to set up the credo integration in Atom. I was getting the same weird C:\.......\\elixir.bat could not be found
error message. I was able to fix it by setting the executable path to the actual path of mix. This fixed the issue for me:
Hope this helps!
@steveklebanoff: TypeError: Cannot read property '1' of null
It looks like a bug. I don't write anything in CoffeeScript for long time, but please try to edit file: ~/.atom/packages/linter-elixir-credo/index.coffee
changing lines 22-31
from:
line = (parseInt(matches[1]) - 1) if matches[1]
col = (parseInt(matches[2]) - 1) if matches[2]
col = 0 if isNaN(col)
error = matches[3]
errors.push {
type: 'Warning',
text: error,
range: [[line, 0], [line, col+1]],
filePath: editor.getPath()
}
to:
if matches
line = (parseInt(matches[1]) - 1) if matches[1]
col = (parseInt(matches[2]) - 1) if matches[2]
col = 0 if isNaN(col)
error = matches[3]
errors.push {
type: 'Warning',
text: error,
range: [[line, 0], [line, col+1]],
filePath: editor.getPath()
}
Note: Number of spaces (indention) is important in CoffeeScript, so I don't removed extra indention here.
property '1' of null
Here null
is matches
(especially call matches[1]
at line: 22
) that is in try
block (lines: 21-31
) and this error is inspected at line 34
.
I installed the plugin, but there does no linting happen, but I do not get any errormessages as well.
When I do run credo manually I do get some output due to missing
@moduledoc
and inconsistent spacing.