Skip to content

Conversation

jmeridth
Copy link
Contributor

Learned we can't get offenses directly off of the cop, it has to be obtained from the commissioner.investigate method.

rubocop sourcecode about not being able to access offenses off the cop base

Learned we have to provide our cop as the forces argument to the commissioner.investigate if we have our own investigate like we do for the overfetch cop. If we don't it never runs. This is not the case with the heredoc cop because it does not have an investigate method.

rubocop commissioner source code where our custom cop invetigate method is actually called that calls this function and you'll notice the second argument is called cops

Learned we can't get offenses directly off of the cop, it has to be
obtained from the commissioner.investigate method.

[rubocop sourcecode about not being able to access offenses off the cop base](https://github.com/rubocop/rubocop/blob/9c6e0ef9039f3602cc0b6e267b7be71ed1110d5b/lib/rubocop/cop/base.rb#L314-L318)

Learned we have to provide our cop as the forces argument to the
commissioner.investigate if we have our own investigate like we do for
the overfetch cop. If we don't it never runs. This is not the case with
the heredoc cop because it does not have an investigate method.

[rubocop commissioner source code where our custom cop invetigate method is actually called](https://github.com/rubocop/rubocop/blob/9c6e0ef9039f3602cc0b6e267b7be71ed1110d5b/lib/rubocop/cop/commissioner.rb#L85)
that calls [this function](https://github.com/rubocop/rubocop/blob/9c6e0ef9039f3602cc0b6e267b7be71ed1110d5b/lib/rubocop/cop/commissioner.rb#L163) and you'll notice the second argument is called cops

Signed-off-by: jmeridth <jmeridth@gmail.com>
Co-authored-by: Hannah Yiu <hkly@github.com>
@jmeridth jmeridth self-assigned this May 29, 2025
@jmeridth jmeridth marked this pull request as draft May 29, 2025 02:54
jmeridth added 2 commits May 28, 2025 22:10
Signed-off-by: jmeridth <jmeridth@gmail.com>
According to [this stackoverflow post](https://stackoverflow.com/a/79361034) by using the 1.3.4 version
of concurrent-ruby gem, this should fix our logging issues.

Signed-off-by: jmeridth <jmeridth@gmail.com>
@jmeridth jmeridth marked this pull request as ready for review May 29, 2025 15:47
@jmeridth
Copy link
Contributor Author

Not the biggest fan of having to pin the concurrent-ruby gem to 1.3.4 but it solves the logging issue. It is a known issue in 1.3.5 (latest) of concurrent-ruby.

@jmeridth jmeridth merged commit 8303e65 into master May 29, 2025
165 checks passed
@jmeridth jmeridth deleted the jm_fix_tests branch May 29, 2025 15:50
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

Successfully merging this pull request may close these issues.

1 participant