-
Notifications
You must be signed in to change notification settings - Fork 0
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
GitCommitBear: Block invalid email addresses #6
base: master
Are you sure you want to change the base?
Conversation
Uses validate_email to check invalid email addresses in git commit message. Fixes coala#1791
Comment on f1548c1. Shortlog of HEAD commit isn't in imperative mood! Bad words are 'trying' GitCommitBear, severity NORMAL, section |
Comment on f1548c1. Shortlog of HEAD commit isn't in imperative mood! Bad words are 'trying' GitCommitBear, severity NORMAL, section |
Comment on f1548c1. Shortlog of HEAD commit isn't in imperative mood! Bad words are 'trying' GitCommitBear, severity NORMAL, section |
Comment on f1548c1. Shortlog of HEAD commit isn't in imperative mood! Bad words are 'trying' GitCommitBear, severity NORMAL, section |
Comment on ec558ce. Shortlog of HEAD commit isn't in imperative mood! Bad words are 'removing' GitCommitBear, severity NORMAL, section |
Comment on f1548c1. Shortlog of HEAD commit isn't in imperative mood! Bad words are 'trying' GitCommitBear, severity NORMAL, section |
Comment on ec558ce. Shortlog of HEAD commit isn't in imperative mood! Bad words are 'removing' GitCommitBear, severity NORMAL, section |
bears/vcs/git/GitCommitBear.py
Outdated
for email in re.findall(r'\w+@+\w+\.+\w*', line): | ||
if is_email(email, diagnose=True, check_dns=True).ERROR_CODES: | ||
invalid_emails = True | ||
result_message += ' ' + email + '\n' |
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
.
bears/vcs/git/GitCommitBear.py
Outdated
@@ -236,6 +239,8 @@ def check_body(self, body, | |||
expressions in this list will be ignored. | |||
:param body_regex: If provided, checks the presence of regex | |||
in the commit body. | |||
:param verify_email: Checks validity of emails in commit body if | |||
present. |
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. (80 > 79)
LineLengthBear, severity NORMAL, section linelength
.
tests/vcs/git/GitCommitBearTest.py
Outdated
# Testing if check recognises invalid emails | ||
self.git_commit('Shortlog\n\n' | ||
'A valid email [email protected]\n' | ||
'An invalid email [email protected]\n' |
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. (87 > 79)
LineLengthBear, severity NORMAL, section linelength
.
tests/vcs/git/GitCommitBearTest.py
Outdated
# Testing if check recognises invalid emails | ||
self.git_commit('Shortlog\n\n' | ||
'A valid email [email protected]\n' | ||
'An invalid email [email protected]\n' |
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.
E501 line too long (87 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
bears/vcs/git/GitCommitBear.py
Outdated
for email in re.findall(r'\w+@+\w+\.+\w*', line): | ||
if is_email(email, diagnose=True, check_dns=True).ERROR_CODES: | ||
invalid_emails = True | ||
result_message += ' ' + email + '\n' |
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.
E501 line too long (82 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
bears/vcs/git/GitCommitBear.py
Outdated
@@ -236,6 +239,8 @@ def check_body(self, body, | |||
expressions in this list will be ignored. | |||
:param body_regex: If provided, checks the presence of regex | |||
in the commit body. | |||
:param verify_email: Checks validity of emails in commit body if | |||
present. |
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.
E501 line too long (80 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
Comment on f1548c1. Shortlog of HEAD commit isn't in imperative mood! Bad words are 'trying' GitCommitBear, severity NORMAL, section |
Comment on ec558ce. Shortlog of HEAD commit isn't in imperative mood! Bad words are 'removing' GitCommitBear, severity NORMAL, section |
tests/vcs/git/GitCommitBearTest.py
Outdated
# Testing if check recognises invalid emails | ||
self.git_commit('Shortlog\n\n' | ||
'A valid email [email protected]\n' | ||
'An invalid email [email protected]\n' |
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.
E501 line too long (87 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
bears/vcs/git/GitCommitBear.py
Outdated
for email in re.findall(r'\w+@+\w+\.+\w*', line): | ||
if is_email(email, diagnose=True, check_dns=True).ERROR_CODES: | ||
invalid_emails = True | ||
result_message += ' ' + email + '\n' |
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.
E501 line too long (82 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
bears/vcs/git/GitCommitBear.py
Outdated
@@ -236,6 +239,8 @@ def check_body(self, body, | |||
expressions in this list will be ignored. | |||
:param body_regex: If provided, checks the presence of regex | |||
in the commit body. | |||
:param verify_email: Checks validity of emails in commit body if | |||
present. |
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.
E501 line too long (80 > 79 characters)'
PycodestyleBear (E501), severity NORMAL, section autopep8
.
tests/vcs/git/GitCommitBearTest.py
Outdated
# Testing if check recognises invalid emails | ||
self.git_commit('Shortlog\n\n' | ||
'A valid email [email protected]\n' | ||
'An invalid email [email protected]\n' |
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. (87 > 79)
LineLengthBear, severity NORMAL, section linelength
.
bears/vcs/git/GitCommitBear.py
Outdated
for email in re.findall(r'\w+@+\w+\.+\w*', line): | ||
if is_email(email, diagnose=True, check_dns=True).ERROR_CODES: | ||
invalid_emails = True | ||
result_message += ' ' + email + '\n' |
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
.
bears/vcs/git/GitCommitBear.py
Outdated
@@ -236,6 +239,8 @@ def check_body(self, body, | |||
expressions in this list will be ignored. | |||
:param body_regex: If provided, checks the presence of regex | |||
in the commit body. | |||
:param verify_email: Checks validity of emails in commit body if | |||
present. |
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. (80 > 79)
LineLengthBear, severity NORMAL, section linelength
.
@@ -260,6 +268,25 @@ def check_body(self, body, | |||
'Commit body lines should not exceed {} ' | |||
'characters.'.format(body_line_length)) | |||
|
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.
E128 continuation line under-indented for visual indent'
PycodestyleBear (E128), severity NORMAL, section autopep8
.
:param valid_email_check: If True, it checks if emails are in valid | ||
format or not | ||
:param email_dns_check: If True, it checks if domains in the emails | ||
are valid or not | ||
""" | ||
if len(body) == 0: |
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.
E225 missing whitespace around operator'
PycodestyleBear (E225), severity NORMAL, section autopep8
.
:param valid_email_check: If True, it checks if emails are in valid | ||
format or not | ||
:param email_dns_check: If True, it checks if domains in the emails | ||
are valid or not | ||
""" |
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.
E225 missing whitespace around operator'
PycodestyleBear (E225), severity NORMAL, section autopep8
.
@@ -260,6 +268,25 @@ def check_body(self, body, | |||
'Commit body lines should not exceed {} ' | |||
'characters.'.format(body_line_length)) | |||
|
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/vcs/git/GitCommitBear.py
+++ b/bears/vcs/git/GitCommitBear.py
@@ -280,7 +280,7 @@
# look up dns
if email_dns_check and email_check:
email_check = not is_email(email, diagnose=True,
- check_dns=True).ERROR_CODES
+ check_dns=True).ERROR_CODES
if not email_check:
invalid_emails = True
result_message += ' ' + email + '\n'
:param valid_email_check: If True, it checks if emails are in valid | ||
format or not | ||
:param email_dns_check: If True, it checks if domains in the emails | ||
are valid or not | ||
""" |
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/vcs/git/GitCommitBear.py
+++ b/bears/vcs/git/GitCommitBear.py
@@ -274,8 +274,8 @@
for line in body:
for email in re.findall(r'\S*@\S*', line):
email_check = re.match(r"(^[a-zA-Z0-9_.+-]"
- +r"+@[a-zA-Z0-9-]+\."
- +r"[a-zA-Z0-9-.]+$)", email)
+ + r"+@[a-zA-Z0-9-]+\."
+ + r"[a-zA-Z0-9-.]+$)", email)
# if eamil do not match regex there is no need to
# look up dns
if email_dns_check and email_check:
Uses validate_email to check invalid email
addresses in git commit message.
Fixes coala#1791
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!