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

CheckstyleBear: Add invalid configuration check #917

Merged
merged 1 commit into from
Nov 6, 2016

Conversation

tylfin
Copy link
Member

@tylfin tylfin commented Oct 20, 2016

Closes #898 ensuring that if the checkstyle_config is google, then use_spaces has to be true and indent_size is 2.

@gitmate-bot
Copy link
Collaborator

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!

@gitmate-bot
Copy link
Collaborator

Comment on 6a010b9.

No newline between shortlog and body at HEAD.

GitCommitBear, severity NORMAL, section commit.

@gitmate-bot
Copy link
Collaborator

Comment on 383b35e.

No newline between shortlog and body at HEAD.

GitCommitBear, severity NORMAL, section commit.

@aptrishu
Copy link
Member

aptrishu commented Oct 23, 2016

Hey @tylfin , Please follow the writing good commits guideline. you can go over here for that http://coala.io/commit . Your commit structure is not right.

First make your commit structure right. Then someone will review you PR very soon. :)

@sils
Copy link
Member

sils commented Oct 25, 2016

@tylfin can you add the Closes note to your message according coala.io/commit?

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

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?

Copy link
Member

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)
Copy link
Collaborator

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

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

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

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

What would you recommend?

Copy link
Member

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")
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 you create a new section on tearDown?

@Makman2
Copy link
Member

Makman2 commented Oct 25, 2016

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

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, ...?

Copy link
Member

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

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

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.

Copy link
Contributor

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"}

Copy link
Contributor

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

@sils
Copy link
Member

sils commented Nov 2, 2016

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

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?

@sils
Copy link
Member

sils commented Nov 2, 2016

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.

@Makman2
Copy link
Member

Makman2 commented Nov 5, 2016

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

sils commented Nov 6, 2016

ack a5ce145

@sils
Copy link
Member

sils commented Nov 6, 2016

@rultor merge

@sils
Copy link
Member

sils commented Nov 6, 2016

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

  • some code reviews for other newcomers
  • fixing at least a difficulty/low issue

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!

@rultor
Copy link

rultor commented Nov 6, 2016

@rultor merge

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

@rultor rultor merged commit a5ce145 into coala:master Nov 6, 2016
@rultor
Copy link

rultor commented Nov 6, 2016

@rultor merge

@sils Done! FYI, the full log is here (took me 1min)

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.

8 participants