-
Notifications
You must be signed in to change notification settings - Fork 577
RuboCopBear: Fix CI breakage #1890
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
Conversation
tests/ruby/RuboCopBearTest.py
Outdated
invalid_files=(bad_file,), | ||
valid_files=(good_file,)) | ||
@generate_skip_decorator(RuboCopBear) | ||
class RuboCopBearTest(LocalBearTestHelper): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not comply to PEP8.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/tests/ruby/RuboCopBearTest.py
+++ b/tests/ruby/RuboCopBearTest.py
@@ -23,6 +23,7 @@
@generate_skip_decorator(RuboCopBear)
class RuboCopBearTest(LocalBearTestHelper):
+
def setUp(self):
self.uut = RuboCopBear(Section('name'), Queue())
8794304
to
97d1d70
Compare
@@ -36,7 +36,7 @@ class RuboCopBear: | |||
def create_arguments(filename, file, config_file, rubocop_config: str=''): | |||
# Need both stdin and filename. Explained in this comment: | |||
# https://github.com/bbatsov/rubocop/pull/2146#issuecomment-131403694 | |||
args = (filename, '--stdin', '--format=json') | |||
args = ('--stdin', filename, '--format=json') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change compatible with earlier versions of rubocop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes 👍 , tested will versions 0.47.1
, 0.48.1
, 0.49.1
|
||
good_file = """def good_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to move the text out into real filenames?
Does rubocop require that there is a valid file with this filename?
Cant LocalBearTestHelper
create temporary files with an appropriate filename/extension?
If it cant, then writing tests is much harder, which is sort of the anti-thesis of your project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, rubocop requires that we have a valid filename extension (.rb
). Temporary files were created in the previous case when we had to use verify_local_bear(...)
but without a valid extension. See the commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, you need to improve LocalBearTestHelper
:P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is a linter specific problem. This is the first linter that I've come across that is careful about the filename extension. Moreover, it would make less sense IMO to improve LocalBearTestHelper
to take care of this case only. Also we had to somehow improve the tests and use check_results(...)
instead of verify_local_bear(...)
.
@Makman2 Tagging you since this PR involved improvisation of tests. |
bears/ruby/RuboCopBear.py
Outdated
@@ -19,7 +19,7 @@ class RuboCopBear: | |||
""" | |||
|
|||
LANGUAGES = {'Ruby'} | |||
REQUIREMENTS = {GemRequirement('rubocop', '0.47.1'), | |||
REQUIREMENTS = {GemRequirement('rubocop'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove the version specification?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our motive is to use the latest version of rubocop. We were using 0.47.1
in the earlier case and due to an upstream release i.e. 0.48
, our CI broke. As a temporary fix, I had to pin the version to 0.47.1
to make sure that the tree was green again. Now that we have a solution, I think it would be a good option to get rid of the pinning and install the latest version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
though I would recommend to fix it currently for 0.48, and upgrade to newer releases explicitly with an issue. But up to you 👍 Not sure actually what our requirements strategy is for bears^^
end_line=2, | ||
end_column=20, | ||
severity=RESULT_SEVERITY.INFO)], | ||
filename=get_testfile_path(filename), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should also check good files 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
You could write into the commit message body that part of the fixing was to improve the tests. |
e1139dc
to
2359913
Compare
Updated @Makman2 |
tests/ruby/RuboCopBearTest.py
Outdated
settings={'indent_size': 1}) | ||
|
||
def test_good_indent_size(self): | ||
filename = 'bad_indent_file.rb' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just call the file indent.rb
, as in this context it isn't bad?
2359913
to
51507c5
Compare
ack 51507c5 |
rubocop/rubocop#4226 indicates that `--stdin` takes filename as an argument which was incorporated. A part of the fixing was to improve the tests that involved the bear to be run on files with the `.rb`(ruby) extension because initially the bear was run on the generated temporary files that was the cause of error. Fixes coala#1548
51507c5
to
d35b120
Compare
reack d35b120 |
@rultor merge |
rubocop/rubocop#4226 indicates that
--stdin
takes filename as an argument which was incorporated. Also, the tests
were enhanced that involved the bear to be run on files with the
.rb
(ruby) extension because initially the bear was run on the generated
temporary files that was the cause of error.
Fixes #1548
For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!
Checklist
them.
individually. It is not sufficient to have "fixup commits" on your PR,
our bot will still report the issues for the previous commit.) You will
likely receive a lot of bot comments and build failures if coala does not
pass on every single commit!
After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.
Please consider helping us by reviewing other peoples pull requests as well:
cobot mark wip <URL>
to get it outof the review queue.
The more you review, the more your score will grow at coala.io and we will
review your PRs faster!