-
Notifications
You must be signed in to change notification settings - Fork 580
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
HTTPSBear.py: New Bear Added #2063
Conversation
bears/general/HTTPSBear.py
Outdated
""" | ||
for result in dependency_results.get(URLBear.name, []): | ||
line_number, link, code, context = result.contents | ||
if (link[0:5]!='https'): |
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.
Origin: PEP8Bear, Section: autopep8
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmps3czyfyb/bears/general/HTTPSBear.py
+++ b/tmp/tmps3czyfyb/bears/general/HTTPSBear.py
@@ -61,7 +61,7 @@
"""
for result in dependency_results.get(URLBear.name, []):
line_number, link, code, context = result.contents
- if (link[0:5]!='https'):
+ if (link[0:5] != 'https'):
httpslink = 'https' + link[4:]
host = urlparse(httpslink).netloc
network_timeout = {urlparse(url).netloc
bears/general/HTTPSBear.py
Outdated
""" | ||
for result in dependency_results.get(URLBear.name, []): | ||
line_number, link, code, context = result.contents | ||
if (link[0:5]!='https'): |
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
Origin: PycodestyleBear (E225), Section: autopep8
.
bears/general/HTTPSBear.py
Outdated
# def __init__(self, origin, affected_code, | ||
# link: str, | ||
# http_status_code: (int, None), | ||
# link_context: LINK_CONTEXT): |
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.
commented code ;)
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.
@Makman2 Yeah still working on it :P I still have to write tests and get it to solve the problem on its own , also remove unnecessary imports :P
bears/general/HTTPSBear.py
Outdated
|
||
from coalib.bears.LocalBear import LocalBear | ||
from dependency_management.requirements.PipRequirement import PipRequirement | ||
from coalib.bearlib import deprecate_settings |
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.
unused import
bears/general/HTTPSBear.py
Outdated
|
||
from coalib.bears.LocalBear import LocalBear | ||
from dependency_management.requirements.PipRequirement import PipRequirement | ||
from coalib.bearlib import deprecate_settings |
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.
Generally many unused imports...
bears/general/HTTPSBear.py
Outdated
'{url}').format(url=link), | ||
file=filename, | ||
line=line_number, | ||
severity=RESULT_SEVERITY.NORMAL) |
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.
we definitely want a patch ;)
bears/general/HTTPSBear.py
Outdated
yield Result.from_values( | ||
origin=self, | ||
message=('You could use https instead of http at - ' | ||
'{url}').format(url=link), |
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.
with a patch you don't have to include the link in the message ;)
bears/general/HTTPSBear.py
Outdated
all your data. | ||
|
||
:param dependency_results: Results given by URLBear. | ||
:param follow_redirects: Set to true to autocorrect redirects. |
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.
-->
:param a:
ABC
:param b:
DEF
bears/general/HTTPSBear.py
Outdated
BEAR_DEPS = {URLBear} | ||
|
||
def run(self, filename, file, dependency_results=dict(), | ||
follow_redirects: bool=False, |
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.
unused parameter
bears/general/HTTPSBear.py
Outdated
else network_timeout.get('*') | ||
if '*' in network_timeout | ||
else URLBear.DEFAULT_TIMEOUT | ||
) |
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.
bad indent ;)
bears/general/HTTPSBear.py
Outdated
end = start + len(link) | ||
replacement = 'https' + link[4:] | ||
replacement = current_line[:start] + | ||
'https' + link[4:] + current_line[end:] |
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.
E113 unexpected indentation
Origin: PycodestyleBear (E113), Section: autopep8
.
bears/general/HTTPSBear.py
Outdated
end = start + len(link) | ||
replacement = 'https' + link[4:] | ||
replacement = current_line[:start] + | ||
'https' + link[4:] + current_line[end:] |
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.
E113 unexpected indentation
Origin: PycodestyleBear (E113), Section: autopep8
.
aed4265
to
2663270
Compare
bears/general/HTTPSBear.py
Outdated
HTTP_PREFIX = 'http' | ||
|
||
def run(self, filename, file, dependency_results=dict(), | ||
network_timeout: typed_dict(str, int, DEFAULT_TIMEOUT)=dict()): |
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.
style change requires spaces around =
@jayvdb So basically this bear needs to use URLHeadBear to get a response for the new https link obtained from http. Problem is that when there is no such link it returns a |
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.
Im happy to let this pragma in. we can worry about that later.
A few style issues.
bears/general/HTTPSBear.py
Outdated
network_timeout = { | ||
urlparse(url).netloc if not url == '*' else '*': timeout | ||
for url, timeout in network_timeout.items()} | ||
httpsresponse = URLHeadBear.get_head_response( |
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.
snake_case
(everywhere)
bears/general/HTTPSBear.py
Outdated
current_line = file[line_number - 1] | ||
start = current_line.find(link) | ||
end = start + len(link) | ||
replacement = current_line[:start] + 'https' + \ |
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.
dont use \
bears/general/HTTPSBear.py
Outdated
|
||
yield Result.from_values( | ||
origin=self, | ||
message=('https can be used instead of http'), |
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 ()
?
HTTPS bear can detect URL links which can be changed to https from http and changes them if the user wants. Closes coala#1900
ack bbfb116 |
@gitmate-bot ff |
Hey! I'm GitMate.io! This pull request is being fastforwarded automatically. Please DO NOT push while fastforward is in progress or your changes would be lost permanently |
Automated fastforward with GitMate.io was successful! 🎉 |
HTTPS bear can detect URL links which can be changed to https
from http and allows to change them automatically.
Closes #1900
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!