jish/pre-commit

outputs the errors twice

Closed this issue · 7 comments

Hi, thanks for the module. Its really helpful.

I get the output of the checks twice for some reason.

pre-commit: Stopping commit because of errors.
Missing semicolon.
public/js/app/app.js:20 ])
Expected an identifier and instead saw '.'.
public/js/app/app.js:26 .constant('apiURL', window.apiURL)
Cannot read property 'id' of undefined
public/js/app/app.js:26 

console.log found:
public/js/app/app.js:20:console.log();

Missing semicolon.
public/js/app/app.js:20 ])
Expected an identifier and instead saw '.'.
public/js/app/app.js:26 .constant('apiURL', window.apiURL)
Cannot read property 'id' of undefined
public/js/app/app.js:26 

console.log found:
public/js/app/app.js:20:console.log();

pre-commit: You can bypass this check using `git commit -n`

I also had some issues installing the module. Like the execjs gem was not installed. Should this be specified in the readme or should it install when the pre-commit gem is installed?

I think it would be nice to display the number of errors or warnings (just an index would do with a bit of indentation)

jish commented

Hmm... that is pretty interesting! =o

What is the command you are typing to get this output?

Can you give us the contents of your pre-commit hook file:

$ cat .git/hooks/pre-commit
#!/usr/bin/env sh

# This hook has a focus on portability.
# This hook will attempt to setup your environment before running checks.
#
# If you would like `pre-commit` to get out of your way and you are comfortable
# setting up your own environment, you can install the manual hook using:
#
#     pre-commit install --manual
#

cmd=`git config pre-commit.ruby 2>/dev/null`
if   test -n "${cmd}"
then true
elif which rvm > /dev/null
then cmd="rvm default do ruby"
elif which rbenv > /dev/null
then cmd="rbenv exec ruby"
else cmd="ruby"
fi

export rvm_silence_path_mismatch_check_flag=1

${cmd} -rrubygems -e '
  begin
    require "pre-commit"
    true
  rescue LoadError => e
    $stderr.puts <<-MESSAGE
pre-commit: WARNING: Skipping checks because: #{e}
pre-commit: Did you set your Ruby version?
MESSAGE
    false
  end and PreCommit.run
'
jish commented

Are you just typing git commit to receive this output? What checks do you have installed? can you paste the output of pre-commit list?

I am only doing git commit. The checks that I am using are (as per the config/pre_commit.yml) file

---
:checks_remove: []
:checks_add:
- :jshint
- :console_log
- :white_space
- :json
- :tabs

pre-commit list outputs

Available providers: default(0) git(10) git_old(11) yaml(20) env(30)
Available checks   : before_all ci closure coffeelint common console_log csslint debugger gemfile_path go jshint jslint json local merge_conflict migration nb_space php pry rails rspec_focus rubocop ruby ruby_symbol_hashrockets scss_lint tabs whitespace yaml
Default   checks   : common rails
Enabled   checks   : common rails jshint console_log white_space json tabs
Evaluated checks   : tabs nb_space whitespace merge_conflict debugger pry local jshint console_log migration jshint console_log white_space json tabs
Default   warnings : 
Enabled   warnings : 
Evaluated warnings :
jish commented

Hmm... it looks like we are erroneously evaluating your list of checks to include jshint and console_log twice :(

Evaluated checks is the line you want to look at.

For now you can remove them from your config/pre_commit.yml to remove the duplicate checks. But we will have to follow up and make sure we do not let checks enter the list more than once.

Oh yea! true. I will remove it, hope that should solve the issue

if I remember correctly the duplication issue was already fixed, please let us know if you still get it