Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codeclimate-rubocop not catching issues #266

Open
imajes opened this issue Dec 22, 2020 · 5 comments
Open

codeclimate-rubocop not catching issues #266

imajes opened this issue Dec 22, 2020 · 5 comments
Assignees

Comments

@imajes
Copy link

imajes commented Dec 22, 2020

Hey climateers,

I'm noticing that for some reason i'm not able to get the codeclimate-rubocop analyzer to be able to find/determine errors.

here's a comparison:

% rubocop   
Inspecting 545 files
................................................................................................................................................................................................................................................................................C................................................................................................................................................................................................................................................................................

Offenses:

config/initializers/cop_trigger.rb:3:1: C: Style/GlobalVars: Do not introduce global variables.
$GLOBAL_BADNESS = "some pointlessly quoted string"
^^^^^^^^^^^^^^^
config/initializers/cop_trigger.rb:3:19: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
$GLOBAL_BADNESS = "some pointlessly quoted string"
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

545 files inspected, 2 offenses detected, 2 offenses auto-correctable

However, when run via CC:

% CODECLIMATE_DEBUG=1 codeclimate analyze -e rubocop:rubocop-0-92
Starting analysis
I, [2020-12-22T00:59:38.100682 #1]  INFO -- : starting engine rubocop
D, [2020-12-22T01:00:02.091052 #1] DEBUG -- : /config.json content: {"enabled"=>true, "channel"=>"rubocop-0-92", "config"=>".rubocop.yml", "include_paths"=>[".better-html.yml", ".browserslistrc", ".bundle/", ".circleci/", ".codeclimate.yml", ".devpack", ".devpack_initializers/", ".dockerignore", ".env.development", ".env.example", ".env.test", ".erb-lint.yml", ".github/", ".gitignore", ".nvmrc", ".pry_history", ".rspec", ".rubocop.yml", ".ruby-gemset", ".ruby-version", ".solargraph.yml", ".stylelintrc", "Dockerfile", "Gemfile", "Gemfile.lock", "Procfile", "README.md", "Rakefile", "app/", "babel.config.js", "bin/", "config.ru", "[REDACTED]_config.ru", "docker-compose.yml", "jest.setup.js", "lib/", "log/", "package.json", "postcss.config.js", "scrap/", "storage/"], "debug"=>"1"}
D, [2020-12-22T01:00:02.109017 #1] DEBUG -- : docker run: ["docker", "run", "--name", "cc-engines-rubocop-rubocop-0-92-73a75734-22e2-475a-aa6b-fd53d20aa0d5", "--cap-drop", "all", "--label", "com.codeclimate.label=a6dc7471-fca1-4bc8-a436-cab68359f5fb", "--log-driver", "none", "--memory-swap", "-1", "--net", "none", "--rm", "--volume", "/Users/james/Projects/[REDACTED]:/code:ro", "--volume", "/tmp/cc/37889be1-43aa-457d-927c-c58889c11881:/config.json:ro", "--user", "9000:9000", "--memory", "1024000000", "codeclimate/codeclimate-rubocop:rubocop-0-92"]
D, [2020-12-22T01:00:47.432874 #1] DEBUG -- : engine stderr: An error occurred while Layout/FirstParameterIndentation cop was inspecting /code/app/[REDACTED].rb:8:4.
D, [2020-12-22T01:00:47.433553 #1] DEBUG -- : engine stderr: To see the complete backtrace run rubocop -d.
D, [2020-12-22T01:00:49.936811 #1] DEBUG -- : engine stderr: An error occurred while Layout/FirstParameterIndentation cop was inspecting /code/app/helpers/[REDACTED]_helper.rb:65:4.
D, [2020-12-22T01:00:49.937796 #1] DEBUG -- : engine stderr: To see the complete backtrace run rubocop -d.
I, [2020-12-22T01:00:55.441913 #1]  INFO -- : finished engine rubocop

Analysis complete! Found 0 issues.
% 

I can't figure out how better to debug this... but it's clear that running via codeclimate isn't getting it done.

relevant portion of .codeclimate.yml:

plugins:
  # Code Climate's default rubocop version is old. This change allows us to control the version Code Climate uses.
  # Channels available: https://github.com/codeclimate/codeclimate-rubocop/branches/all?utf8=✓&query=channel%2Frubocop
  # https://docs.codeclimate.com/docs/rubocop
  rubocop:
    enabled: true
    channel: rubocop-0-92
    config:
      file: .rubocop.yml

halps? :) (sorry @ale7714 , but cc'ing you in because i know y'all super busy, but i am blocked on this - thanks)

@imajes
Copy link
Author

imajes commented Dec 29, 2020

@fede-moya happy holidays! 🎄 ☃️

just wondered if you happened to have any time to look at this -- it feels like (i hope) a simple fix :D

@ale7714
Copy link
Contributor

ale7714 commented Dec 30, 2020

@imajes happy holidays! we are having issues reproducing this bug. Could you please share a sample code where you're experiencing this issue? If you don't feel comfortable sharing over here. Please, send an email to [email protected] so we can take a look at what's going on. Thank you!

@ale7714 ale7714 assigned noelia-lencina and unassigned f-moya Dec 30, 2020
@imajes
Copy link
Author

imajes commented Dec 30, 2020

@ale7714 thanks for replying! I pinged you back via the RLS slack -- it may be easier to zoom or something to quickly dive in. Thank you for being so awesome and on top of all these things! ❤️

@f-moya
Copy link

f-moya commented Jan 11, 2021

@imajes

Could be the case that the code we discussed is not valid ruby code ? As we discussed, our theory was right and you are not seeing any rubocop issues because the ruby-parser is failing at some point.

I have run the parser latest version, 3.0.0 against the following code and and I have received the following error message.

def hello(
  a,
  b,
)
  puts "#{a} - #{b}"
end

hello("Parameter A", "Parameter B")
hello.rb:4:1: error: unexpected token tRPAREN
hello.rb:4: )
hello.rb:4: ^

Which is exactly the same parser error that I remember seeing in the logs.

Also trying to run that also cause and error

>> ruby hello.rb
hello.rb:4: syntax error, unexpected ')'
hello.rb:6: syntax error, unexpected `end', expecting end-of-input

All those problems go away if we remove the comma after argument b, seems like it's not valid ruby. Like this:

def hello(
  a,
  b
)
  puts "#{a} - #{b}"
end

hello("Parameter A", "Parameter B")

Might that extra comma got introduced by mistake ? 🤔

@imajes
Copy link
Author

imajes commented Jan 15, 2021

@fede-moya i triple checked, and there's no dangling comma. Sorry man. it's not the error :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants