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

Undefined method `begin' for PseudoSourceRange #55

Closed
nononoy opened this issue Nov 7, 2021 · 6 comments · Fixed by #56
Closed

Undefined method `begin' for PseudoSourceRange #55

nononoy opened this issue Nov 7, 2021 · 6 comments · Fixed by #56
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@nononoy
Copy link

nononoy commented Nov 7, 2021

I'm getting an error during execution. Can provide more details if needed

undefined method `begin' for #<RuboCop::Cop::Offense::PseudoSourceRange:0x000055906792fa48>
Did you mean?  begin_pos
/home/runner/work/_actions/reviewdog/action-rubocop/v2/rdjson_formatter/rdjson_formatter.rb:41:in `build_diagnostic'

Workflow config:

jobs:
  rubocop:
    name: rubocop
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v1
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 2.7.1
      - name: rubocop
        uses: reviewdog/action-rubocop@v2
        with:
          rubocop_version: 0.90.0
          rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile
          reporter: github-pr-review
          fail_on_error: true
@johnofsydney
Copy link

I had the same issue and swapped uses: reviewdog/action-rubocop@v2 to uses: reviewdog/action-rubocop@v1

Everything seems to be working ok now

@mgrachev mgrachev added bug Something isn't working help wanted Extra attention is needed labels Nov 12, 2021
@jeremybdk
Copy link

jeremybdk commented Nov 15, 2021

I also have the same issue since updating to v2, can I help somehow?

@ohbarye
Copy link
Member

ohbarye commented Nov 16, 2021

I guess the suggestion feature that is introduced since v2 is related to the error.

line: range.begin.line,
column: range.begin.column + 1 # rubocop is 0-origin, reviewdog is 1-origin

@nononoy @johnofsydney @jeremybdk
Could you give me an example Ruby code to reproduce the error?

@jeremybdk
Copy link

jeremybdk commented Nov 16, 2021

@ohbarye The thing is I don't really know what's causing this error, as it's always present, is there a way to have more details about the error?

@owst
Copy link

owst commented Nov 17, 2021

@ohbarye @jeremybdk I was able to reproduce in a simple way:

$ mkdir repro && cd repro
$ git clone git@github.com:reviewdog/action-rubocop.git
Cloning into 'action-rubocop'...
[...]
$ gem install rubocop
Successfully installed rubocop-1.23.0
[...]

$ touch empty_file.rb
$ rubocop empty_file.rb
Inspecting 1 file
W

Offenses:

empty_file.rb:1:1: W: Lint/EmptyFile: Empty file detected.

1 file inspected, 1 offense detected

$ rubocop --require ./action-rubocop/rdjson_formatter/rdjson_formatter.rb --format RdjsonFormatter empty_file.rb
{"source":{"name":"rubocop","url":"https://rubocop.org/"},"diagnostics":[]}
undefined method `begin' for #<RuboCop::Cop::Offense::PseudoSourceRange:0x00007f9dd5949ab0>
Did you mean?  begin_pos
/private/tmp/repro/action-rubocop/rdjson_formatter/rdjson_formatter.rb:41:in `build_diagnostic'
/private/tmp/repro/action-rubocop/rdjson_formatter/rdjson_formatter.rb:19:in `block in file_finished'
/private/tmp/repro/action-rubocop/rdjson_formatter/rdjson_formatter.rb:18:in `each'
/private/tmp/repro/action-rubocop/rdjson_formatter/rdjson_formatter.rb:18:in `file_finished'
[...]

I wonder if rubocop/rubocop#8823 will give any insight to the fix - it sounds like it fixed a (very?) similar issue: rubocop/rubocop#8718

@ohbarye
Copy link
Member

ohbarye commented Nov 18, 2021

Thanks @owst , I figured out the cause. Let me try to fix in #56.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants