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

KeywordBear.py: Output appropriate message #1271

Merged
merged 1 commit into from
Jan 11, 2017

Conversation

Techievena
Copy link
Member

Output appropriate message if the language given in input is not valid/not supported for KeywordBear

Fixes #1256

@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!

for result in annotation_bear_results:
yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')
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. (86 > 79)

LineLengthBear, severity NORMAL, section linelength.

yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')

Copy link
Collaborator

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

SpaceConsistencyBear, severity NORMAL, section python.

The issue can be fixed by applying the following patch:

--- a/bears/general/KeywordBear.py
+++ b/bears/general/KeywordBear.py
@@ -23,7 +23,7 @@
             yield from result.contents.get('comments', [])
     except Exception:
         raise TypeError('Given Language in the input is not supported by KeywordBear')
-    
+
 
 
 def generate_diff(comments, file, filename,

yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')



def generate_diff(comments, file, filename,
Copy link
Collaborator

Choose a reason for hiding this comment

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

E303 too many blank lines (3)'

PycodestyleBear (E303), severity NORMAL, section autopep8.

yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')

Copy link
Collaborator

Choose a reason for hiding this comment

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

W293 blank line contains whitespace'

PycodestyleBear (W293), severity NORMAL, section autopep8.

for result in annotation_bear_results:
yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')
Copy link
Collaborator

Choose a reason for hiding this comment

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

E501 line too long (86 > 79 characters)'

PycodestyleBear (E501), severity NORMAL, section autopep8.

@gitmate-bot
Copy link
Collaborator

Comment on 5c94a92.

Body of HEAD commit contains too long lines. Commit body lines should not exceed 72 characters.

GitCommitBear, severity NORMAL, section commit.

for result in annotation_bear_results:
yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')
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/general/KeywordBear.py
+++ b/bears/general/KeywordBear.py
@@ -22,8 +22,8 @@
         for result in annotation_bear_results:
             yield from result.contents.get('comments', [])
     except Exception:
-        raise TypeError('Given Language in the input is not supported by KeywordBear')
-    
+        raise TypeError(
+            'Given Language in the input is not supported by KeywordBear')
 
 
 def generate_diff(comments, file, filename,

yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')

Copy link
Collaborator

Choose a reason for hiding this comment

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

Line contains following spacing inconsistencies:

  • Trailing whitespaces.

SpaceConsistencyBear, severity NORMAL, section python.

The issue can be fixed by applying the following patch:

--- a/bears/general/KeywordBear.py
+++ b/bears/general/KeywordBear.py
@@ -23,7 +23,7 @@
             yield from result.contents.get('comments', [])
     except Exception:
         raise TypeError('Given Language in the input is not supported by KeywordBear')
-    
+
 
 def generate_diff(comments, file, filename,
                   line, line_number, pos):

for result in annotation_bear_results:
yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')
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. (86 > 79)

LineLengthBear, severity NORMAL, section linelength.

@gitmate-bot
Copy link
Collaborator

Comment on 6c77db6.

Body of HEAD commit contains too long lines. Commit body lines should not exceed 72 characters.

GitCommitBear, severity NORMAL, section commit.

yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')

Copy link
Collaborator

Choose a reason for hiding this comment

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

W293 blank line contains whitespace'

PycodestyleBear (W293), severity NORMAL, section autopep8.

for result in annotation_bear_results:
yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')
Copy link
Collaborator

Choose a reason for hiding this comment

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

E501 line too long (86 > 79 characters)'

PycodestyleBear (E501), severity NORMAL, section autopep8.

for result in annotation_bear_results:
yield from result.contents.get('comments', [])
except Exception:
raise TypeError('Given Language in the input is not supported by KeywordBear')
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/general/KeywordBear.py
+++ b/bears/general/KeywordBear.py
@@ -22,8 +22,9 @@
         for result in annotation_bear_results:
             yield from result.contents.get('comments', [])
     except Exception:
-        raise TypeError('Given Language in the input is not supported by KeywordBear')
-    
+        raise TypeError(
+            'Given Language in the input is not supported by KeywordBear')
+
 
 def generate_diff(comments, file, filename,
                   line, line_number, pos):

@gitmate-bot
Copy link
Collaborator

Comment on 9b94b80.

Body of HEAD commit contains too long lines. Commit body lines should not exceed 72 characters.

GitCommitBear, severity NORMAL, section commit.

@Shade5
Copy link

Shade5 commented Jan 7, 2017

KeywordBear.py is not fully covered by the tests. You'll have to add tests for 100% coverage

@Shade5
Copy link

Shade5 commented Jan 7, 2017

Run py.test --cov to check coverage. You have to get 100% coverage for KeywordBear.py

try:
for result in annotation_bear_results:
yield from result.contents.get('comments', [])
except AttributeError:
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@aptrishu I think it's a lot simpler to use github as the main review UI, just copying the text from gitter makes it way easier for other reviewers to see what's going on here

@Techievena
Copy link
Member Author

@Shade5 Need help in writing test case

@Shade5
Copy link

Shade5 commented Jan 10, 2017

Does py.test work fine without your changes?
Show me the output of py.test -k KeywordBearTest --cov

@Techievena
Copy link
Member Author

Here is it @Shade5
image

@Shade5
Copy link

Shade5 commented Jan 10, 2017

So you need to write two tests. One that satisties the if at 23 and another that does not. Add those tests to KeywordBearTest.py

@Techievena
Copy link
Member Author

Yes I am trying to cover the log statements using assertLogs but they are failing. Can you have a look on test case I have wrriten

@Shade5
Copy link

Shade5 commented Jan 10, 2017

How are you calling _get_comments() in your test?

@Techievena
Copy link
Member Author

Techievena commented Jan 10, 2017

I think execute_bear is calling them. I mean it is executing KeywordBear so _get_comments( ) automatically gets called.

@Shade5
Copy link

Shade5 commented Jan 10, 2017

Any errors with py.test -k KeywordBearTest --cov ?

@Techievena
Copy link
Member Author

I've imported logging in both Keyword.py and KeywordBearTest.py and py.test -k KeywordBearTest --cov is returning the same as before

@Techievena
Copy link
Member Author

image

'AnnotationBear': [
annotation_bear_result_type(
'coalang specification for anything not found.'
)
Copy link
Member

Choose a reason for hiding this comment

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

We end the brackets/parantheses in the same line as the last element. See line 207 of this file.


text = ['# todo 123']

with execute_bear(self.uut, 'F', text,
Copy link
Member

Choose a reason for hiding this comment

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

Please use named arguments - they're easier to read. Every other test uses them and consistent is better :)

See line 211 of this file.

dependency_results=dep_results) as result:
self.assertEqual(result[0].diffs, {})
self.assertEqual(result[0].affected_code[0].start.line, 1)
self.assertEqual(len(result), 1)
Copy link
Member

Choose a reason for hiding this comment

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

this should probably be the first assert :3

Copy link
Member

Choose a reason for hiding this comment

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

And there aren't any checks to make sure the message is logged? I mean, that's what the whole PR is about.

@Techievena
Copy link
Member Author

@adtac Done with the changes. Is it mergeable now? 😃

yield from result.contents.get('comments', [])
if isinstance(result.contents, str):
logging.error(result.contents)
yield []
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 yield an empty list? I'd just remove it.

Copy link
Member

Choose a reason for hiding this comment

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

what if I'm expecting a list? not yielding a list might trigger an exception

Copy link
Member Author

Choose a reason for hiding this comment

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

As it was yeilding an empty list when comments key was not found in request.contents I thought I had to do the same in case when this execption arises.
Fine I'll remove it 👍

Copy link
Member

Choose a reason for hiding this comment

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

uhm yield is not a return @adtac

Copy link
Member

Choose a reason for hiding this comment

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

ah didn't realize the original was a yield from, not a yield

Output appropriate message if the language
given in input is not valid/not supported
for KeywordBear

Fixes coala#1256
@sils
Copy link
Member

sils commented Jan 11, 2017

ack 75ae1c9

@sils
Copy link
Member

sils commented Jan 11, 2017

@rultor merge

@rultor
Copy link

rultor commented Jan 11, 2017

@rultor merge

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

@rultor rultor merged commit 75ae1c9 into coala:master Jan 11, 2017
@rultor
Copy link

rultor commented Jan 11, 2017

@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