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

Apply coala patches #41

Merged
merged 12 commits into from
Dec 27, 2017
Merged

Apply coala patches #41

merged 12 commits into from
Dec 27, 2017

Conversation

manu-chroma
Copy link
Owner

No description provided.

Copy link
Collaborator

@jayvdb jayvdb left a comment

Choose a reason for hiding this comment

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

IMO, this patch should be held back in the queue, and used as a guide to help us with code reviews.

Many parts of this will be rewritten during GCI, especially data being moved out into data files, and as part of that we could ask that new code follows the new coding standards.

@manu-chroma manu-chroma force-pushed the apply-coala-patches branch 5 times, most recently from dc57180 to 249e6c1 Compare December 26, 2017 16:05
@manu-chroma manu-chroma requested a review from jayvdb December 26, 2017 16:09
@manu-chroma
Copy link
Owner Author

manu-chroma commented Dec 26, 2017

@jayvdb Ref to: https://travis-ci.org/manu-chroma/username-availability-checker/builds/321837314#L846
Is increasing line limit only way to get around this error?

Update: @biscuitsnake is again working on her patch. This will cause conflicts

Your call John on how we should handle this one 😅

@jayvdb
Copy link
Collaborator

jayvdb commented Dec 26, 2017

Is increasing line limit only way to get around this error?

no. see https://github.com/coala/coala-bears/blob/master/bears/general/LineLengthBear.py#L23

cli.py Outdated
sites = list(map(lambda x: '{}.com'.format(x),
"facebook twitter instagram github youtube soundcloud tumblr".split()))
sites = list(map(lambda x: '{}.com'.format(x),
'facebook twitter instagram \
Copy link
Collaborator

Choose a reason for hiding this comment

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

this list should be derived from the yaml, as the list is now out of date. especially, wtf does youtube come from? :P maybe cli.py isnt too useful if nobody has noticed that youtube results here are not sensible.

anyway, as a general rule the continuation marker \ should be avoided. Use of it is almost always unnecessary, and it is rarely supported properly by linters because it is a override that breaks most of the rules of the language.

In this case, consecutive strings are automatically concatenated if they are inside any multiline context.
i.e.

a = ('facebook twitter instagram '
'github youtube soundcloud tumblr')

Copy link
Owner Author

Choose a reason for hiding this comment

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

Fixing the linting errors for now.
I realise how badly cli.py is broken (also, we used to support YouTube back in the day ) :P

I will open an issue to fix it separately. It is low priority and we can choose to actually fix or remove the file for later.

username_api.py Outdated

def check_format(website, username):
"""Check the format of a username depending on the website"""
'""Check the format of a username depending on the website""'
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a horrible bug in coala. ^ is not a docstring.

use

"""Check the format of a username depending on the website.
"""

.coafile Outdated
@@ -30,7 +30,7 @@ use_spaces = true
files = templates/*.html
bears = LineLengthBear, SpaceConsistencyBear
use_spaces = true
max_line_length = 100
max_line_length = 700
Copy link
Collaborator

Choose a reason for hiding this comment

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

too high to be useful.

need to find ways to bring that down, configuring the bears, excluding specific files, etc.

import string

from parameterized import parameterized
import pytest
import os.path
Copy link
Collaborator

Choose a reason for hiding this comment

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

these were recently corrected in master. this is probably a merge mistake


message = None
if expected != actual:
message = 'The provided available username ({}) ' \
Copy link
Collaborator

Choose a reason for hiding this comment

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

\ is an abomination :P

string concatenation doesnt need line continuation.

increasing the line length for python would be reasonable IMO.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I was very strictly trying to adhere to PEP8 limit :P

json_resp = json.loads(resp.get_data().decode())
url = username_api.get_profile_url(website, username)
assert {
'possible': False,
Copy link
Collaborator

Choose a reason for hiding this comment

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

personally, I prefer the existing layout.

    assert {
        'possible': False,
        'url': url
    } == json_resp

or its inverse

    assert json_resp == {
      'possible': False,
      'url': url
    }

You've also kept that style at https://github.com/manu-chroma/username-availability-checker/pull/41/files#diff-86cae0060e15d8121c1f9029f69f7517R82

url = username_api.get_profile_url(website, username)
assert {
'possible': False,
'url': url
Copy link
Collaborator

Choose a reason for hiding this comment

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

you may like to impose trailing commas in this patch, but doing that would change this line, which means git blame -w will be broken by this patch.

pytest.skip('website not supported')
link = username_api.check_username(website, user)['avatar']
response = r.get(link)
assert(response.headers.get('content-type', '').startswith('image/') or
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unrelated to your patch, but good to include now as it is another whitespace only change ...

assert(.. looks like a function call.

instead, adding a space can help ensure people see a function call was not intended

assert (..

@manu-chroma manu-chroma force-pushed the apply-coala-patches branch 2 times, most recently from 31933ac to 6782f17 Compare December 27, 2017 13:53
@manu-chroma
Copy link
Owner Author

@jayvdb :)

This patch is for *.py files. Includes:
- consistant indentation for all files
- patches from PEP8Bear, PycodestyleBear
- PyCharm's inspect code analysis
- other bears in .coafile
- optimise imports
To not cause version conflict when
installing coala.
Ignore long links in CSS and
ignore svg path tags in HMTL.

This helps in reducing HTML line length down
to a more meaningful number, to be useful.
@manu-chroma manu-chroma merged commit dc15296 into master Dec 27, 2017
@manu-chroma manu-chroma deleted the apply-coala-patches branch November 8, 2018 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants