Flower merge requestshttps://code.mayfirst.org/mfmt/flower/-/merge_requests2021-05-14T14:48:13Zhttps://code.mayfirst.org/mfmt/flower/-/merge_requests/2WIP - Issue #4: Install pre commit for code linting & formatting2021-05-14T14:48:13ZTimWIP - Issue #4: Install pre commit for code linting & formattingFYI -- this includes the changes from the previous PR for issue #4 but I think should probably be reviewed differently.
This is definitely a conversation starter, and I'm sure we'll have to work more to get it right, but wanted to open ...FYI -- this includes the changes from the previous PR for issue #4 but I think should probably be reviewed differently.
This is definitely a conversation starter, and I'm sure we'll have to work more to get it right, but wanted to open the conversation -- I went through installing my normal suite of code linting/formatting tools, running them against the codebase, and then trying to fix the issues that were identified.
One of the great things about code linting is it finds and fixes minor typos (like a file where `gettext` wasn't imported, or variables referenced by the wrong name). I hope I made the right call in these place..
There were some errors which I couldn't figure out how to address, because I don't understand the code well enough yet -- any thoughts on the below errors?
Also! Some of the `models.py` and `views.py` files are super-long which makes it hard to scan what all is in them. Would you be open to a further commit or separate PR which breaks them up into individual files for each model within a `models/` directory instead? I've done that on projects before and had it work well.
`
Messages
========
flowerhub/authorizer.py:
L10:2 None: pep8 - N816
variable 'threadLocal' in global scope should not be mixedCase
flowerhub/authorizer.py:
L15:15 None: pep8 - N805
first argument of a method should be named 'self'
flowerhub.authorizer (flowerhub/authorizer.py):
L15:4 Authz.init: pylint - no-self-argument
Method should have "self" as first argument
flowerhub/authorizer.py:
L36:28 None: pep8 - N805
first argument of a method should be named 'self'
flowerhub.authorizer (flowerhub/authorizer.py):
L36:4 Authz.has_member_access: pylint - no-self-argument
Method should have "self" as first argument
flowerhub/authorizer.py:
L52:36 None: pep8 - N805
first argument of a method should be named 'self'
flowerhub.authorizer (flowerhub/authorizer.py):
L52:4 Authz.get_permissioned_queryset: pylint - no-self-argument
Method should have "self" as first argument
flowerhub.authorizer (flowerhub/authorizer.py):
L19:8 Authz.init: pylint - using-constant-test
Using a conditional statement with a constant value
flowerhub.authorizer (flowerhub/authorizer.py):
L22:12 Authz.init: pylint - using-constant-test
Using a conditional statement with a constant value
flowerhub.authorizer (flowerhub/authorizer.py):
L25:4 Authz.get_username: pylint - no-method-argument
Method has no argument
flowerhub.authorizer (flowerhub/authorizer.py):
L28:4 Authz.is_superuser: pylint - no-method-argument
Method has no argument
flowerhub.authorizer (flowerhub/authorizer.py):
L31:4 Authz.is_authenticated: pylint - no-method-argument
Method has no argument
flowerhub.authorizer (flowerhub/authorizer.py):
L37:8 Authz.has_member_access: pylint - import-outside-toplevel
Import outside toplevel (flowerhub.models.Access)
flowerhub.authorizer (flowerhub/authorizer.py):
L53:8 Authz.get_permissioned_queryset: pylint - import-outside-toplevel
Import outside toplevel (flowerhub.models.Member)
Check Information
=================
Started: 2021-04-30 13:58:25.702061
Finished: 2021-04-30 13:58:32.113852
Time Taken: 6.41 seconds
Formatter: text
Profiles: .prospector.yaml, strictness_high, strictness_veryhigh, full_pep8, no_doc_warnings, no_test_warnings, no_member_warnings
Strictness: from profile
Libraries Used: django
Tools Run: dodgy, mccabe, pep8, profile-validator, pyflakes, pylint
Messages Found: 14
Messages
========
flower.settings (flower/settings.py):
L212:- None: dodgy - secret
Possible hardcoded secret key
flower/settings.py:
L192:13 None: pyflakes - F401
'flower.settings_local_production_hub.*' imported but unused
flower.settings (flower/settings.py):
L192:12 None: pylint - wildcard-import
Wildcard import flower.settings_local_production_hub
flower/settings.py:
L195:13 None: pyflakes - F401
'flower.settings_local_production_petal.*' imported but unused
flower.settings (flower/settings.py):
L195:12 None: pylint - wildcard-import
Wildcard import flower.settings_local_production_petal
flower/settings.py:
L202:13 None: pyflakes - F401
'flower.settings_local_test_hub.*' imported but unused
flower.settings (flower/settings.py):
L202:12 None: pylint - wildcard-import
Wildcard import flower.settings_local_test_hub
flower/settings.py:
L205:13 None: pyflakes - F401
'flower.settings_local_test_petal.*' imported but unused
flower.settings (flower/settings.py):
L205:12 None: pylint - wildcard-import
Wildcard import flower.settings_local_test_petal
flowerhub/models.py:
L494:10 None: pep8 - N806
variable 'RESPONSES' in function should be lowercase
flowerhub/models.py:
L1916:17 None: pyflakes - F841
local variable 'allowed_networks' is assigned to but never used
flowerhub.models (flowerhub/models.py):
L1:- None: pylint - too-many-lines
Too many lines in module (3303/1000)
flowerhub.models (flowerhub/models.py):
L197:17 valid_ssh_public_key_file: pylint - subprocess-run-check
Using subprocess.run without explicitly set `check` is not recommended.
flowerhub.models (flowerhub/models.py):
L599:8 MemberResource.setup_runners: pylint - unnecessary-pass
Unnecessary pass statement
flowerhub.models (flowerhub/models.py):
L615:16 MemberResource.create_runners: pylint - not-callable
ro is not callable
flowerhub.models (flowerhub/models.py):
L1106:4 Member.delete: pylint - signature-differs
Signature differs from overridden 'delete' method
flowerhub.models (flowerhub/models.py):
L1247:4 DomainZone.delete: pylint - signature-differs
Signature differs from overridden 'delete' method
flowerhub.models (flowerhub/models.py):
L1371:4 DomainZoneRunner.submit: pylint - arguments-differ
Parameters differ from overridden 'submit' method
flowerhub.models (flowerhub/models.py):
L1914:16 DomainName.clean: pylint - unused-variable
Unused variable 'allowed_networks'
flowerhub.models (flowerhub/models.py):
L2088:4 MailingListDomain.delete: pylint - signature-differs
Signature differs from overridden 'delete' method
flowerpetal.resourcer (flowerpetal/resourcer.py):
L24:- resource_factory: pylint - too-many-return-statements
Too many return statements (19/6)
flowerpetal.resourcer (flowerpetal/resourcer.py):
L93:19 ResourcerCommon.run: pylint - broad-except
Catching too general exception Exception
flowerpetal.resourcer (flowerpetal/resourcer.py):
L148:17 ResourcerCommon.execute: pylint - subprocess-run-check
Using subprocess.run without explicitly set `check` is not recommended.
Check Information
=================
Started: 2021-04-30 13:58:25.702503
Finished: 2021-04-30 13:58:54.323101
Time Taken: 28.62 seconds
Formatter: text
Profiles: .prospector.yaml, strictness_high, strictness_veryhigh, full_pep8, no_doc_warnings, no_test_warnings, no_member_warnings
Strictness: from profile
Libraries Used: django
Tools Run: dodgy, mccabe, pep8, profile-validator, pyflakes, pylint
Messages Found: 23
Messages
========
runners (flowerhub/management/commands/runners.py):
L71:4 Command.get_status_constant: pylint - inconsistent-return-statements
Either all return statements in a function should return an expression, or none of them should.
flowerhub.migrations.0001_initial (flowerhub/migrations/0001_initial.py):
L1:- None: pylint - too-many-lines
Too many lines in module (2261/1000)
flowerpetal.views (flowerpetal/views.py):
L41:15 process_resource: pylint - broad-except
Catching too general exception Exception
Check Information
=================
Started: 2021-04-30 13:58:25.703348
Finished: 2021-04-30 13:58:38.761386
Time Taken: 13.06 seconds
Formatter: text
Profiles: .prospector.yaml, strictness_high, strictness_veryhigh, full_pep8, no_doc_warnings, no_test_warnings, no_member_warnings
Strictness: from profile
Libraries Used: django
Tools Run: dodgy, mccabe, pep8, profile-validator, pyflakes, pylint
Messages Found: 3
Messages
========
flowerhub.views (flowerhub/views.py):
L462:34 WebsiteFormMixin.form_valid: pylint - undefined-variable
Undefined variable 'mysql_database_id'
flowerhub/views.py:
L469:17 None: pyflakes - F523
'...'.format(...) has unused arguments at position(s): 1
flowerhub.views (flowerhub/views.py):
L469:16 WebsiteFormMixin.form_valid: pylint - too-many-format-args
Too many arguments for format string
flowerhub.views (flowerhub/views.py):
L1:- None: pylint - too-many-lines
Too many lines in module (2673/1000)
flowerhub.views (flowerhub/views.py):
L536:32 WebsiteFormMixin.get_form: pylint - protected-access
Access to a protected member _meta of a client class
flowerhub.views (flowerhub/views.py):
L548:8 WebsiteFormMixin.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L549:8 WebsiteFormMixin.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L553:8 WebsiteFormMixin.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L554:8 WebsiteFormMixin.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L630:17 DemoView.build_template_vars: pylint - unused-variable
Unused variable 'seconds'
flowerhub.views (flowerhub/views.py):
L993:8 LoginUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L994:8 LoginUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1124:35 DomainNameUpdateView.get_context_data: pylint - no-value-for-parameter
No value for argument 'self' in unbound method call
flowerhub.views (flowerhub/views.py):
L1173:35 DomainNameCreateView.get_context_data: pylint - no-value-for-parameter
No value for argument 'self' in unbound method call
flowerhub.views (flowerhub/views.py):
L1302:8 MailingListDomainUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1303:8 MailingListDomainUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1337:8 MailingListDomainCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1338:8 MailingListDomainCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1405:8 MailingListUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1406:8 MailingListUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1438:8 MailingListCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1439:8 MailingListCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1650:8 EmailAliasUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1651:8 EmailAliasUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1685:8 EmailAliasCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1686:8 EmailAliasCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1953:8 EmailMailboxUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1954:8 EmailMailboxUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1958:8 EmailMailboxUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L1959:8 EmailMailboxUpdateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L2003:8 EmailMailboxCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L2004:8 EmailMailboxCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L2008:8 EmailMailboxCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'kwargs' defined outside __init__
flowerhub.views (flowerhub/views.py):
L2009:8 EmailMailboxCreateView.get_context_data: pylint - attribute-defined-outside-init
Attribute 'request' defined outside __init__
flowerhub.views (flowerhub/views.py):
L2483:12 ajax_mx_options: pylint - unused-variable
Unused variable 'd2'
`