whitesmith / rubycritic

A Ruby code quality reporter
MIT License
3.36k stars 223 forks source link

With Docker rubycritic not working #244

Closed jagadishwer closed 4 years ago

jagadishwer commented 7 years ago

running reek smells ............................................................................../usr/local/bundle/gems/parser-2.4.0.0/lib/parser/source/buffer.rb:164:in source=': invalid byte sequence in US-ASCII (EncodingError) from /usr/local/bundle/gems/reek-4.7.1/lib/reek/source/source_code.rb:99:inparse' from /usr/local/bundle/gems/reek-4.7.1/lib/reek/source/source_code.rb:33:in initialize' from /usr/local/bundle/gems/reek-4.7.1/lib/reek/source/source_code.rb:50:innew' from /usr/local/bundle/gems/reek-4.7.1/lib/reek/source/source_code.rb:50:in from' from /usr/local/bundle/gems/reek-4.7.1/lib/reek/examiner.rb:40:ininitialize' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/analysers/helpers/reek.rb:8:in initialize' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/analysers/smells/reek.rb:30:innew' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/analysers/smells/reek.rb:30:in add_smells_to' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/analysers/smells/reek.rb:17:inblock in run' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/core/analysed_modules_collection.rb:27:in each' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/core/analysed_modules_collection.rb:27:ineach' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/analysers/smells/reek.rb:16:in run' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/analysers_runner.rb:30:inblock in run' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/analysers_runner.rb:27:in each' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/analysers_runner.rb:27:inrun' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/commands/default.rb:24:in critique' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/commands/default.rb:19:inexecute' from /usr/local/bundle/gems/rubycritic-3.2.3/lib/rubycritic/cli/application.rb:20:in execute' from /usr/local/bundle/gems/rubycritic-3.2.3/bin/rubycritic:10:in<top (required)>' from /usr/local/bundle/bin/rubycritic:17:in load' from /usr/local/bundle/bin/rubycritic:17:in

'

nunosilva800 commented 7 years ago

Hi @jagadishwer, looks like a problem with reek itself.

Are you able to run only reek on your project or file, and report it on its repository: https://github.com/troessner/reek/issues?

IMhide commented 6 years ago

I have the same error on docker but in a different spot :

$ gem install rubycritic
Successfully installed sexp_processor-4.11.0
Successfully installed ruby_parser-3.11.0
Successfully installed erubis-2.7.0
Successfully installed path_expander-1.0.3
Successfully installed flay-2.12.0
Successfully installed flog-4.6.2
Successfully installed public_suffix-3.0.2
Successfully installed addressable-2.5.2
Successfully installed launchy-2.4.3
Successfully installed ast-2.4.0
Successfully installed parser-2.5.1.0
Successfully installed rainbow-3.0.0
Successfully installed thread_safe-0.3.6
Successfully installed descendants_tracker-0.0.4
Successfully installed equalizer-0.0.11
Successfully installed coercible-1.0.0
Successfully installed ice_nine-0.11.2
Successfully installed axiom-types-0.1.1
Successfully installed virtus-1.0.5
Successfully installed codeclimate-engine-rb-0.4.1
Successfully installed reek-4.8.2
Successfully installed tty-which-0.3.0
Successfully installed rubycritic-3.4.0
23 gems installed
$ env
LC_ALL=en_US.UTF-8
...
LANGUAGE=en_US.UTF-8
...
RUBY_VERSION=2.3.7
GEM_HOME=/usr/local/bundle
...
PWD=/builds/Sam/Intranet
..
_=/usr/bin/env
$ rubycritic app lib/utils --no-browser
running flay smells
.......................
running flog smells
....................................................................................................................................................
running reek smells
....................................................................................................................................................
running complexity
....................................................................................................................................................
running attributes
....................................................................................................................................................
running churn
....................................................................................................................................................
/usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html/line.rb:22:in `delete': invalid byte sequence in US-ASCII (ArgumentError)
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html/line.rb:22:in `render'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html/code_file.rb:31:in `block in render'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html/code_file.rb:28:in `each'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html/code_file.rb:28:in `with_index'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html/code_file.rb:28:in `render'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html_report.rb:36:in `block (2 levels) in create_directories_and_files'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html_report.rb:35:in `open'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html_report.rb:35:in `block in create_directories_and_files'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html_report.rb:33:in `each'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html_report.rb:33:in `create_directories_and_files'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/generators/html_report.rb:20:in `generate_report'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/reporter.rb:6:in `generate_report'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/commands/default.rb:29:in `report'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/commands/default.rb:19:in `execute'
    from /usr/local/bundle/gems/rubycritic-3.4.0/lib/rubycritic/cli/application.rb:20:in `execute'
    from /usr/local/bundle/gems/rubycritic-3.4.0/bin/rubycritic:10:in `<top (required)>'
    from /usr/local/bundle/bin/rubycritic:23:in `load'
    from /usr/local/bundle/bin/rubycritic:23:in `<main>'
cvoltz commented 5 years ago

With the current master branch, I can run rubycritic in Docker and it runs without generating errors but it doesn't process the files:

!!! Running `rubycritic` rake command
!!! Inspecting ["exe/", "lib/"] with options  --deduplicate-symlinks --format console --format html --minimum-score 0 --no-browser --path artifacts/rubycritic

warning: parser/current is loading parser/ruby26, which recognizes
warning: 2.6.3-compliant syntax, but you are running 2.6.2.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Uncommitted changes are present.

Using the same Dockerfile, if I just change the Gemfile from:

gem "rubycritic", require: false, git: "https://github.com/whitesmith/rubycritic.git"

to

gem "rubycritic", require: false

rubycritic will generate output:

!!! Running `rubycritic` rake command
!!! Inspecting ["exe/", "lib/"] with options  --deduplicate-symlinks --format console --format html --minimum-score 0 --no-browser --path artifacts/rubycritic --suppress-ratings

warning: parser/current is loading parser/ruby26, which recognizes
warning: 2.6.3-compliant syntax, but you are running 2.6.2.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
running flay smells

running flog smells
..
running reek smells
..
running complexity
..
running attributes
..
running churn
..

I found that I can get it to work again if I use 10985559cbe255e4840b5d5d982178d1ca827ddf (i.e., by reverting #306). I did that by changing the Gemfile to:

gem "rubycritic", require: false,
  git: "https://github.com/whitesmith/rubycritic.git", ref: 109855
KaitakuShiba commented 4 years ago

I also used Docker and encountered an invalid byte sequence in US-ASCII (ArgumentError) error.Add ENV for Dockerfile and work for me.

ENV LC_ALL=C.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8

reference: https://github.com/ffaker/ffaker/issues/277

danilobarion1986 commented 4 years ago

I also used Docker and encountered an invalid byte sequence in US-ASCII (ArgumentError) error.Add ENV for Dockerfile and work for me.

ENV LC_ALL=C.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8

reference: ffaker/ffaker#277

This solved for me too! Can we close this issue?