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

RuboCopBear: Fix CI breakage #1890

Merged
merged 1 commit into from Jul 6, 2017
Merged

Conversation

yash-nisar
Copy link
Member

@yash-nisar yash-nisar commented Jul 5, 2017

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

  • I read the commit guidelines and I've followed
    them.
  • I ran coala over my code locally. (All commits have to pass
    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:

The more you review, the more your score will grow at coala.io and we will
review your PRs faster!

invalid_files=(bad_file,),
valid_files=(good_file,))
@generate_skip_decorator(RuboCopBear)
class RuboCopBearTest(LocalBearTestHelper):
Copy link
Collaborator

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())
 

@@ -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')
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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(...).

@yash-nisar
Copy link
Member Author

@Makman2 Tagging you since this PR involved improvisation of tests.

@@ -19,7 +19,7 @@ class RuboCopBear:
"""

LANGUAGES = {'Ruby'}
REQUIREMENTS = {GemRequirement('rubocop', '0.47.1'),
REQUIREMENTS = {GemRequirement('rubocop'),
Copy link
Member

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?

Copy link
Member Author

@yash-nisar yash-nisar Jul 6, 2017

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.

Copy link
Member

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),
Copy link
Member

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 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

@Makman2
Copy link
Member

Makman2 commented Jul 5, 2017

You could write into the commit message body that part of the fixing was to improve the tests.

@yash-nisar yash-nisar force-pushed the rubocop-investigation branch 3 times, most recently from e1139dc to 2359913 Compare July 6, 2017 07:39
@yash-nisar
Copy link
Member Author

Updated @Makman2

settings={'indent_size': 1})

def test_good_indent_size(self):
filename = 'bad_indent_file.rb'
Copy link
Member

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?

@Makman2
Copy link
Member

Makman2 commented Jul 6, 2017

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
@Makman2
Copy link
Member

Makman2 commented Jul 6, 2017

reack d35b120

@Makman2
Copy link
Member

Makman2 commented Jul 6, 2017

@rultor merge

@rultor
Copy link

rultor commented Jul 6, 2017

@rultor merge

@Makman2 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit d35b120 into coala:master Jul 6, 2017
@rultor
Copy link

rultor commented Jul 6, 2017

@rultor merge

@Makman2 Done! FYI, the full log is here (took me 2min)

@yash-nisar yash-nisar deleted the rubocop-investigation branch July 6, 2017 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

rubocop 0.48 breaks CI
5 participants