-
Notifications
You must be signed in to change notification settings - Fork 581
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
CheckstyleBear: Add invalid configuration check #917
Conversation
Thanks for your contribution! Reviewing pull requests take really a lot of time and we're all volunteers. Please make sure you go through the following check list and complete them all before pinging someone for a review.
As you learn things over your Pull Request please help others on the chat and on PRs to get their stuff right as well! |
Comment on 6a010b9. No newline between shortlog and body at HEAD. GitCommitBear, severity NORMAL, section |
Comment on 383b35e. No newline between shortlog and body at HEAD. GitCommitBear, severity NORMAL, section |
Hey @tylfin , Please follow the First make your commit structure right. Then someone will review you PR very soon. :) |
@tylfin can you add the |
@@ -10,6 +10,13 @@ | |||
"geosoft": "http://geosoft.no/development/geosoft_checks.xml"} | |||
|
|||
|
|||
def invalid_configuration(checkstyle_configs, use_spaces, indent_size): | |||
if checkstyle_configs != 'google': | |||
return |
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.
rather return False
right? Also you could just return checkstyle_configs == 'google' and ...
to make it a oneliner, right?
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.
also I think you should research for the other configs on what's invalid for those and include those cases in here
@@ -10,6 +10,10 @@ | |||
"geosoft": "http://geosoft.no/development/geosoft_checks.xml"} | |||
|
|||
|
|||
def invalid_configuration(checkstyle_configs, use_spaces, indent_size): | |||
return checkstyle_configs == 'google' and (not use_spaces or indent_size != 2) |
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.
Line is longer than allowed. (82 > 79)
LineLengthBear, severity NORMAL, section linelength
.
@@ -10,6 +10,11 @@ | |||
"geosoft": "http://geosoft.no/development/geosoft_checks.xml"} | |||
|
|||
|
|||
def invalid_configuration(checkstyle_configs, use_spaces, indent_size): | |||
return checkstyle_configs == 'google' and \ | |||
(not use_spaces or indent_size != 2) |
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.
would you mind using braces instead of \
? :)
-->
return (...
continues here)
self, filename, file, config_file, | ||
checkstyle_configs: known_checkstyle_or_path="google", | ||
use_spaces: bool = True, indent_size: int = 2 | ||
): |
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.
please no spaces around =
for default arguments + align the ):
onto the previous line :)
@@ -64,6 +71,9 @@ def create_arguments( | |||
- geosoft - The Java style followed by GeoSoft. More info at | |||
<http://geosoft.no/development/javastyle.html> | |||
""" | |||
if invalid_configuration(checkstyle_configs, use_spaces, indent_size): | |||
raise ValueError('Invalid configuration! Cannot proceed.') |
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.
could you be a bit more precise with the 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.
What would you recommend?
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.
"Google checkstyle
config conflicts with your use_spaces
or indent_size
"
It is not ideal. Maybe invalid_configuration
should raise the exception, so that the message can be:
"Google checkstyle
config does not support use_spaces|indent_size
=x
"
@@ -22,6 +22,9 @@ def setUp(self): | |||
self.empty_config = os.path.join(test_files, | |||
"checkstyle_empty_config.xml") | |||
|
|||
def tearDown(self): | |||
self.section = Section("test section") |
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 you create a new section on tearDown
?
some minor things left to do, but the direction is right 👍 :D |
self, filename, file, config_file, | ||
checkstyle_configs: known_checkstyle_or_path="google"): | ||
def create_arguments(self, filename, file, config_file, | ||
checkstyle_configs: known_checkstyle_or_path="google", |
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/bears/java/CheckstyleBear.py
+++ b/bears/java/CheckstyleBear.py
@@ -48,8 +48,8 @@
"checkstyle.jar")
def create_arguments(self, filename, file, config_file,
- checkstyle_configs: known_checkstyle_or_path="google",
- use_spaces: bool=True, indent_size: int = 2):
+ checkstyle_configs: known_checkstyle_or_path="google",
+ use_spaces: bool=True, indent_size: int = 2):
"""
:param checkstyle_configs:
A file containing configs to use in ``checkstyle``. It can also
@@ -10,6 +10,11 @@ | |||
"geosoft": "http://geosoft.no/development/geosoft_checks.xml"} | |||
|
|||
|
|||
def invalid_configuration(checkstyle_configs, use_spaces, indent_size): | |||
return (checkstyle_configs == 'google' and | |||
(not use_spaces or indent_size != 2)) |
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/bears/java/CheckstyleBear.py
+++ b/bears/java/CheckstyleBear.py
@@ -12,7 +12,7 @@
def invalid_configuration(checkstyle_configs, use_spaces, indent_size):
return (checkstyle_configs == 'google' and
- (not use_spaces or indent_size != 2))
+ (not use_spaces or indent_size != 2))
def known_checkstyle_or_path(setting):
@@ -43,8 +48,9 @@ def setup_dependencies(self): | |||
"checkstyle.jar") | |||
|
|||
def create_arguments( | |||
self, filename, file, config_file, | |||
checkstyle_configs: known_checkstyle_or_path="google"): | |||
self, filename, file, config_file, |
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/bears/java/CheckstyleBear.py
+++ b/bears/java/CheckstyleBear.py
@@ -48,9 +48,9 @@
"checkstyle.jar")
def create_arguments(
- self, filename, file, config_file,
- checkstyle_configs: known_checkstyle_or_path="google",
- use_spaces: bool=True, indent_size: int = 2):
+ self, filename, file, config_file,
+ checkstyle_configs: known_checkstyle_or_path="google",
+ use_spaces: bool=True, indent_size: int = 2):
"""
:param checkstyle_configs:
A file containing configs to use in ``checkstyle``. It can also
@@ -10,6 +10,11 @@ | |||
"geosoft": "http://geosoft.no/development/geosoft_checks.xml"} | |||
|
|||
|
|||
def invalid_configuration(checkstyle_configs, use_spaces, indent_size): | |||
return (checkstyle_configs == 'google' and | |||
(not use_spaces or indent_size != 2)) |
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/bears/java/CheckstyleBear.py
+++ b/bears/java/CheckstyleBear.py
@@ -12,7 +12,7 @@
def invalid_configuration(checkstyle_configs, use_spaces, indent_size):
return (checkstyle_configs == 'google' and
- (not use_spaces or indent_size != 2))
+ (not use_spaces or indent_size != 2))
def known_checkstyle_or_path(setting):
if (checkstyle_configs is 'google' and | ||
(not use_spaces or indent_size != 2)): | ||
raise ValueError('Google checkstyle config does not support ' + | ||
'use_spaces=False or indent_size != 2') |
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.
what about the other configs? sun, geosoft, ...?
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.
let's open another issue for that, at least we know from google that these settings don't fit together.
@@ -44,7 +51,8 @@ def setup_dependencies(self): | |||
|
|||
def create_arguments( | |||
self, filename, file, config_file, | |||
checkstyle_configs: known_checkstyle_or_path="google"): | |||
checkstyle_configs: known_checkstyle_or_path="google", | |||
use_spaces: bool=True, indent_size: int = 2): |
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.
spaces around second =
:)
def check_invalid_configuration(checkstyle_configs, use_spaces, indent_size): | ||
if (checkstyle_configs is 'google' and | ||
(not use_spaces or indent_size != 2)): | ||
raise ValueError('Google checkstyle config does not support ' + |
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 not necessary or desirable here . Python automatically concatenates static string nodes in the AST.
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.
bump
@@ -10,6 +10,13 @@ | |||
"geosoft": "http://geosoft.no/development/geosoft_checks.xml"} | |||
|
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.
regarding commit body: use "Adds" instead of "Add" (NOT in the shortlog, but in the body!)
also, end sentences with period please
can you please use the full issue url, not just the number? Number onlky works in github, not on git locally. |
@@ -10,6 +10,13 @@ | |||
"geosoft": "http://geosoft.no/development/geosoft_checks.xml"} | |||
|
|||
|
|||
def check_invalid_configuration(checkstyle_configs, use_spaces, indent_size): | |||
if (checkstyle_configs is 'google' and |
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 plural? This is one config, not multiple... can you file an issue about renaming them or add another commit on top doing that?
ok the code looks good, I want to get this merged. Also it seems like this has done quite a number of reviews already :/ One rebase, ping us and we'll merge it? Ideally correct the commit messsage with the issue URL. |
@tylfin if you don't mind, could you make another rebase? sorry that this has gone so "long-term" :) |
Adds invalid_config function to CheckstyleBear.py. Adds tests for invalid configurations. Closes coala#898.
ack a5ce145 |
@rultor merge |
Hey, this is your first contribution, right? Congrats and welcome to the coalaians! :) You can help us a lot by filling out http://coala.io/newform! Rultor will now automatically release your changes as a prerelease so users can experience the goodness of your changes right now. See also https://github.com/coala-analyzer/coala/wiki/coala-Steam-Offer btw. We would really appreciate it if you could help us with
We're all volunteers and we're currently struggling to keep this up. Helping all those newcomers is a lot of work and we do need your help so we can continue this for others! |
Closes #898 ensuring that if the checkstyle_config is google, then use_spaces has to be true and indent_size is 2.