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

Use pylint to ensure code quality - 5 errors were detected #82

Open
oussjarrousse opened this issue Jan 5, 2024 · 6 comments
Open

Use pylint to ensure code quality - 5 errors were detected #82

oussjarrousse opened this issue Jan 5, 2024 · 6 comments

Comments

@oussjarrousse
Copy link

Pylint is a linter for python, there are several plugins for different frameworks and use cases such as the pylint-django plugin.
Using pylint with pylint-django plugin I got the following result:

install it with:

(venv) $ pip3 install pylint pylint-django
(venv) $ pylint --load-plugins=pylint_django --django-settings-module=mfa --errors-only mfa

************* Module mfa.FIDO2
mfa/FIDO2.py:80:12: E0401: Unable to import 'raven.contrib.django.raven_compat.models' (import-error)
mfa/FIDO2.py:143:16: E0401: Unable to import 'raven.contrib.django.raven_compat.models' (import-error)
mfa/FIDO2.py:180:74: E1101: Instance of 'Exception' has no 'message' member (no-member)
************* Module mfa.middleware
mfa/middleware.py:3:0: E0401: Unable to import 'django.core.urlresolvers' (import-error)
mfa/middleware.py:3:0: E0611: No name 'urlresolvers' in module 'django.core' (no-name-in-module)

And the full output...

(venv) $ pylint --load-plugins=pylint_django --django-settings-module=mfa  mfa
************* Module mfa
mfa/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
************* Module mfa.totp
mfa/totp.py:32:0: C0301: Line too long (101/100) (line-too-long)
mfa/totp.py:34:0: C0301: Line too long (102/100) (line-too-long)
mfa/totp.py:50:0: C0301: Line too long (109/100) (line-too-long)
mfa/totp.py:62:0: C0301: Line too long (162/100) (line-too-long)
mfa/totp.py:75:0: C0301: Line too long (120/100) (line-too-long)
mfa/totp.py:76:0: C0301: Line too long (141/100) (line-too-long)
mfa/totp.py:78:0: C0301: Line too long (114/100) (line-too-long)
mfa/totp.py:88:0: C0301: Line too long (110/100) (line-too-long)
mfa/totp.py:89:0: C0301: Line too long (102/100) (line-too-long)
mfa/totp.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/totp.py:5:0: W0401: Wildcard import models (wildcard-import)
mfa/totp.py:16:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/totp.py:25:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/totp.py:29:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/totp.py:30:12: C0415: Import outside toplevel (time) (import-outside-toplevel)
mfa/totp.py:32:19: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/totp.py:34:19: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/totp.py:38:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/totp.py:41:8: C0103: Variable name "tokenLength" doesn't conform to snake_case naming style (invalid-name)
mfa/totp.py:58:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/totp.py:58:0: C0103: Function name "getToken" doesn't conform to snake_case naming style (invalid-name)
mfa/totp.py:64:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/totp.py:75:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/totp.py:6:0: C0411: third party import "from django.template.context_processors import csrf" should be placed before "from .Common import get_redirect_url" (wrong-import-order)
mfa/totp.py:7:0: C0411: third party import "import simplejson" should be placed before "from .Common import get_redirect_url" (wrong-import-order)
mfa/totp.py:8:0: C0411: third party import "from django.conf import settings" should be placed before "from .Common import get_redirect_url" (wrong-import-order)
mfa/totp.py:9:0: C0411: third party import "import pyotp" should be placed before "from .Common import get_redirect_url" (wrong-import-order)
mfa/totp.py:11:0: C0411: standard import "import datetime" should be placed before "from django.shortcuts import render" (wrong-import-order)
mfa/totp.py:12:0: C0411: third party import "from django.utils import timezone" should be placed before "from .Common import get_redirect_url" (wrong-import-order)
mfa/totp.py:13:0: C0411: standard import "import random" should be placed before "from django.shortcuts import render" (wrong-import-order)
mfa/totp.py:8:0: C0412: Imports from package django are not grouped (ungrouped-imports)
mfa/totp.py:12:0: C0412: Imports from package django are not grouped (ungrouped-imports)
mfa/totp.py:5:0: W0614: Unused import(s) models, JSONField and jwt from wildcard import of models (unused-wildcard-import)
************* Module mfa.FIDO2
mfa/FIDO2.py:53:0: C0301: Line too long (109/100) (line-too-long)
mfa/FIDO2.py:71:0: C0301: Line too long (164/100) (line-too-long)
mfa/FIDO2.py:72:0: C0301: Line too long (133/100) (line-too-long)
mfa/FIDO2.py:91:0: C0301: Line too long (108/100) (line-too-long)
mfa/FIDO2.py:92:0: C0301: Line too long (105/100) (line-too-long)
mfa/FIDO2.py:139:0: C0301: Line too long (143/100) (line-too-long)
mfa/FIDO2.py:160:0: C0301: Line too long (118/100) (line-too-long)
mfa/FIDO2.py:165:0: C0301: Line too long (118/100) (line-too-long)
mfa/FIDO2.py:166:0: C0301: Line too long (107/100) (line-too-long)
mfa/FIDO2.py:175:0: C0301: Line too long (108/100) (line-too-long)
mfa/FIDO2.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/FIDO2.py:1:0: C0103: Module name "FIDO2" doesn't conform to snake_case naming style (invalid-name)
mfa/FIDO2.py:12:0: W0401: Wildcard import models (wildcard-import)
mfa/FIDO2.py:29:0: C0103: Function name "getServer" doesn't conform to snake_case naming style (invalid-name)
mfa/FIDO2.py:39:8: W1406: The u prefix for strings is no longer necessary in Python >=3.0 (redundant-u-string-prefix)
mfa/FIDO2.py:40:8: W1406: The u prefix for strings is no longer necessary in Python >=3.0 (redundant-u-string-prefix)
mfa/FIDO2.py:41:8: W1406: The u prefix for strings is no longer necessary in Python >=3.0 (redundant-u-string-prefix)
mfa/FIDO2.py:76:11: W0718: Catching too general exception Exception (broad-exception-caught)
mfa/FIDO2.py:71:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/FIDO2.py:77:8: C0415: Import outside toplevel (traceback) (import-outside-toplevel)
mfa/FIDO2.py:82:8: W0702: No exception type(s) specified (bare-except)
mfa/FIDO2.py:80:12: E0401: Unable to import 'raven.contrib.django.raven_compat.models' (import-error)
mfa/FIDO2.py:80:12: C0415: Import outside toplevel (raven.contrib.django.raven_compat.models.client) (import-outside-toplevel)
mfa/FIDO2.py:76:4: W0612: Unused variable 'exp' (unused-variable)
mfa/FIDO2.py:96:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/FIDO2.py:96:0: C0103: Function name "getUserCredentials" doesn't conform to snake_case naming style (invalid-name)
mfa/FIDO2.py:103:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/FIDO2.py:108:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/FIDO2.py:117:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/FIDO2.py:117:0: R0914: Too many local variables (20/15) (too-many-locals)
mfa/FIDO2.py:179:11: W0718: Catching too general exception Exception (broad-exception-caught)
mfa/FIDO2.py:141:15: W0718: Catching too general exception Exception (broad-exception-caught)
mfa/FIDO2.py:138:19: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/FIDO2.py:145:12: W0702: No exception type(s) specified (bare-except)
mfa/FIDO2.py:143:16: E0401: Unable to import 'raven.contrib.django.raven_compat.models' (import-error)
mfa/FIDO2.py:143:16: C0415: Import outside toplevel (raven.contrib.django.raven_compat.models.client) (import-outside-toplevel)
mfa/FIDO2.py:147:19: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/FIDO2.py:151:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/FIDO2.py:152:12: C0415: Import outside toplevel (time) (import-outside-toplevel)
mfa/FIDO2.py:154:19: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/FIDO2.py:157:12: C0415: Import outside toplevel (random) (import-outside-toplevel)
mfa/FIDO2.py:170:20: W0702: No exception type(s) specified (bare-except)
mfa/FIDO2.py:174:50: C0321: More than one statement on a single line (multiple-statements)
mfa/FIDO2.py:175:31: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/FIDO2.py:177:27: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/FIDO2.py:180:15: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/FIDO2.py:180:74: E1101: Instance of 'Exception' has no 'message' member (no-member)
mfa/FIDO2.py:117:0: R0911: Too many return statements (7/6) (too-many-return-statements)
mfa/FIDO2.py:117:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
mfa/FIDO2.py:13:0: C0411: third party import "from fido2.utils import websafe_decode, websafe_encode" should be placed before "from .models import *" (wrong-import-order)
mfa/FIDO2.py:14:0: C0411: third party import "from fido2.webauthn import AttestedCredentialData" should be placed before "from .models import *" (wrong-import-order)
mfa/FIDO2.py:16:0: C0411: standard import "import datetime" should be placed before "from fido2.client import Fido2Client" (wrong-import-order)
mfa/FIDO2.py:18:0: C0411: third party import "from django.utils import timezone" should be placed before "from .models import *" (wrong-import-order)
mfa/FIDO2.py:19:0: C0411: third party import "from django.http import JsonResponse" should be placed before "from .models import *" (wrong-import-order)
mfa/FIDO2.py:9:0: C0412: Imports from package fido2 are not grouped (ungrouped-imports)
mfa/FIDO2.py:10:0: C0412: Imports from package django are not grouped (ungrouped-imports)
mfa/FIDO2.py:13:0: C0412: Imports from package fido2 are not grouped (ungrouped-imports)
mfa/FIDO2.py:18:0: C0412: Imports from package django are not grouped (ungrouped-imports)
mfa/FIDO2.py:1:0: W0611: Unused Fido2Client imported from fido2.client (unused-import)
mfa/FIDO2.py:12:0: W0614: Unused import(s) models, JSONField and jwt from wildcard import of models (unused-wildcard-import)
************* Module mfa.recovery
mfa/recovery.py:22:0: C0301: Line too long (102/100) (line-too-long)
mfa/recovery.py:28:0: C0301: Line too long (116/100) (line-too-long)
mfa/recovery.py:39:0: W0311: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
mfa/recovery.py:40:0: W0311: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
mfa/recovery.py:41:0: W0311: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
mfa/recovery.py:42:0: W0311: Bad indentation. Found 12 spaces, expected 8 (bad-indentation)
mfa/recovery.py:81:0: C0301: Line too long (101/100) (line-too-long)
mfa/recovery.py:83:0: C0301: Line too long (102/100) (line-too-long)
mfa/recovery.py:94:0: C0301: Line too long (109/100) (line-too-long)
mfa/recovery.py:96:0: C0301: Line too long (107/100) (line-too-long)
mfa/recovery.py:100:0: C0301: Line too long (111/100) (line-too-long)
mfa/recovery.py:103:0: C0301: Line too long (115/100) (line-too-long)
mfa/recovery.py:105:72: C0303: Trailing whitespace (trailing-whitespace)
mfa/recovery.py:122:0: C0304: Final newline missing (missing-final-newline)
mfa/recovery.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/recovery.py:7:0: W0401: Wildcard import models (wildcard-import)
mfa/recovery.py:16:0: C0115: Missing class docstring (missing-class-docstring)
mfa/recovery.py:20:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/recovery.py:20:0: C0103: Function name "delTokens" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:27:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/recovery.py:27:0: C0103: Function name "randomGen" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:31:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/recovery.py:31:0: C0103: Function name "genTokens" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:36:4: C0103: Variable name "hashedKeys" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:37:4: C0103: Variable name "clearKeys" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:40:12: C0103: Variable name "hashedToken" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:38:8: W0612: Unused variable 'i' (unused-variable)
mfa/recovery.py:53:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/recovery.py:57:8: C0103: Variable name "hashedToken" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:58:14: R1704: Redefining argument with the local name 'token' (redefined-argument-from-local)
mfa/recovery.py:67:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/recovery.py:67:0: C0103: Function name "getTokenLeft" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:69:4: C0103: Variable name "keyLeft" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:71:8: C0103: Variable name "keyLeft" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:74:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/recovery.py:78:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/recovery.py:79:12: C0415: Import outside toplevel (time) (import-outside-toplevel)
mfa/recovery.py:81:19: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/recovery.py:83:19: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/recovery.py:87:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/recovery.py:88:4: C0415: Import outside toplevel (views.login) (import-outside-toplevel)
mfa/recovery.py:91:8: C0103: Variable name "tokenLength" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:94:12: C0103: Variable name "resBackup" doesn't conform to snake_case naming style (invalid-name)
mfa/recovery.py:8:0: C0411: third party import "import simplejson" should be placed before "from .Common import get_redirect_url" (wrong-import-order)
mfa/recovery.py:9:0: C0411: standard import "import random" should be placed before "from django.shortcuts import render" (wrong-import-order)
mfa/recovery.py:10:0: C0411: standard import "import string" should be placed before "from django.shortcuts import render" (wrong-import-order)
mfa/recovery.py:11:0: C0411: standard import "import datetime" should be placed before "from django.shortcuts import render" (wrong-import-order)
mfa/recovery.py:12:0: C0411: third party import "from django.utils import timezone" should be placed before "from .Common import get_redirect_url" (wrong-import-order)
mfa/recovery.py:12:0: C0412: Imports from package django are not grouped (ungrouped-imports)
mfa/recovery.py:11:0: W0611: Unused import datetime (unused-import)
mfa/recovery.py:7:0: W0614: Unused import(s) models, JSONField and jwt from wildcard import of models (unused-wildcard-import)
************* Module mfa.models
mfa/models.py:8:0: C0301: Line too long (116/100) (line-too-long)
mfa/models.py:29:0: C0301: Line too long (133/100) (line-too-long)
mfa/models.py:30:0: C0301: Line too long (131/100) (line-too-long)
mfa/models.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/models.py:8:8: W0707: Consider explicitly re-raising using 'except ModuleNotFoundError as exc' and 'raise ModuleNotFoundError("Can't find a JSONField implementation, please install jsonfield if django < 4.0") from exc' (raise-missing-from)
mfa/models.py:17:0: C0115: Missing class docstring (missing-class-docstring)
mfa/models.py:17:0: C0103: Class name "User_Keys" doesn't conform to PascalCase naming style (invalid-name)
mfa/models.py:17:0: W5102: Found __unicode__ method on model (User_Keys). Python3 uses __str__. (model-has-unicode)
mfa/models.py:30:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments)
mfa/models.py:33:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
mfa/models.py:11:0: C0412: Imports from package django are not grouped (ungrouped-imports)
************* Module mfa.ApproveLogin
mfa/ApproveLogin.py:1:0: C0103: Module name "ApproveLogin" doesn't conform to snake_case naming style (invalid-name)
************* Module mfa.apps
mfa/apps.py:4:0: C0304: Final newline missing (missing-final-newline)
mfa/apps.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/apps.py:2:0: C0115: Missing class docstring (missing-class-docstring)
mfa/apps.py:2:0: C0103: Class name "myAppNameConfig" doesn't conform to PascalCase naming style (invalid-name)
************* Module mfa.TrustedDevice
mfa/TrustedDevice.py:67:0: C0301: Line too long (120/100) (line-too-long)
mfa/TrustedDevice.py:90:0: C0301: Line too long (102/100) (line-too-long)
mfa/TrustedDevice.py:102:0: C0301: Line too long (122/100) (line-too-long)
mfa/TrustedDevice.py:129:0: C0301: Line too long (134/100) (line-too-long)
mfa/TrustedDevice.py:133:0: C0301: Line too long (102/100) (line-too-long)
mfa/TrustedDevice.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/TrustedDevice.py:1:0: C0103: Module name "TrustedDevice" doesn't conform to snake_case naming style (invalid-name)
mfa/TrustedDevice.py:7:0: W0401: Wildcard import models (wildcard-import)
mfa/TrustedDevice.py:12:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/TrustedDevice.py:14:4: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/TrustedDevice.py:14:58: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
mfa/TrustedDevice.py:14:85: C0321: More than one statement on a single line (multiple-statements)
mfa/TrustedDevice.py:17:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/TrustedDevice.py:17:0: C0103: Function name "getUserAgent" doesn't conform to snake_case naming style (invalid-name)
mfa/TrustedDevice.py:18:4: W0622: Redefining built-in 'id' (redefined-builtin)
mfa/TrustedDevice.py:27:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/TrustedDevice.py:34:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/TrustedDevice.py:34:0: C0103: Function name "checkTrusted" doesn't conform to snake_case naming style (invalid-name)
mfa/TrustedDevice.py:36:4: W0622: Redefining built-in 'id' (redefined-builtin)
mfa/TrustedDevice.py:41:8: W0702: No exception type(s) specified (bare-except)
mfa/TrustedDevice.py:40:53: C0321: More than one statement on a single line (multiple-statements)
mfa/TrustedDevice.py:45:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/TrustedDevice.py:45:0: C0103: Function name "getCookie" doesn't conform to snake_case naming style (invalid-name)
mfa/TrustedDevice.py:51:8: C0415: Import outside toplevel (datetime.datetime, datetime.timedelta) (import-outside-toplevel)
mfa/TrustedDevice.py:45:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
mfa/TrustedDevice.py:58:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/TrustedDevice.py:60:4: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/TrustedDevice.py:67:102: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
mfa/TrustedDevice.py:68:8: W0612: Unused variable 'cookie' (unused-variable)
mfa/TrustedDevice.py:89:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/TrustedDevice.py:103:4: W0702: No exception type(s) specified (bare-except)
mfa/TrustedDevice.py:101:11: C0121: Comparison 'td == None' should be 'td is None' (singleton-comparison)
mfa/TrustedDevice.py:101:21: C0321: More than one statement on a single line (multiple-statements)
mfa/TrustedDevice.py:108:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/TrustedDevice.py:110:4: C0415: Import outside toplevel (Common.send) (import-outside-toplevel)
mfa/TrustedDevice.py:123:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/TrustedDevice.py:125:8: W0621: Redefining name 'jwt' from outer scope (line 7) (redefined-outer-name)
mfa/TrustedDevice.py:125:8: C0415: Import outside toplevel (jose.jwt) (import-outside-toplevel)
mfa/TrustedDevice.py:135:12: W0702: No exception type(s) specified (bare-except)
mfa/TrustedDevice.py:129:108: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
mfa/TrustedDevice.py:136:16: C0415: Import outside toplevel (traceback) (import-outside-toplevel)
mfa/TrustedDevice.py:8:0: C0411: third party import "import user_agents" should be placed before "from .models import *" (wrong-import-order)
mfa/TrustedDevice.py:9:0: C0411: third party import "from django.utils import timezone" should be placed before "from .models import *" (wrong-import-order)
mfa/TrustedDevice.py:10:0: C0411: third party import "from django.urls import reverse" should be placed before "from .models import *" (wrong-import-order)
mfa/TrustedDevice.py:9:0: C0412: Imports from package django are not grouped (ungrouped-imports)
mfa/TrustedDevice.py:5:0: W0611: Unused RequestContext imported from django.template.context (unused-import)
mfa/TrustedDevice.py:7:0: W0614: Unused import(s) models, JSONField and jwt from wildcard import of models (unused-wildcard-import)
************* Module mfa.admin
mfa/admin.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/admin.py:1:0: W0611: Unused admin imported from django.contrib (unused-import)
************* Module mfa.Common
mfa/Common.py:18:0: C0301: Line too long (103/100) (line-too-long)
mfa/Common.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/Common.py:1:0: C0103: Module name "Common" doesn't conform to snake_case naming style (invalid-name)
mfa/Common.py:5:0: W0702: No exception type(s) specified (bare-except)
mfa/Common.py:8:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/Common.py:12:4: C0103: Variable name "From" doesn't conform to snake_case naming style (invalid-name)
mfa/Common.py:12:11: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
mfa/Common.py:17:0: C0116: Missing function or method docstring (missing-function-docstring)
************* Module mfa.Email
mfa/Email.py:37:0: C0301: Line too long (104/100) (line-too-long)
mfa/Email.py:40:0: C0301: Line too long (120/100) (line-too-long)
mfa/Email.py:42:0: C0301: Line too long (116/100) (line-too-long)
mfa/Email.py:59:0: C0301: Line too long (109/100) (line-too-long)
mfa/Email.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/Email.py:1:0: C0103: Module name "Email" doesn't conform to snake_case naming style (invalid-name)
mfa/Email.py:4:0: C0410: Multiple imports on one line (datetime, random) (multiple-imports)
mfa/Email.py:6:0: W0401: Wildcard import models (wildcard-import)
mfa/Email.py:11:0: C0103: Function name "sendEmail" doesn't conform to snake_case naming style (invalid-name)
mfa/Email.py:13:4: C0415: Import outside toplevel (django.contrib.auth.get_user_model) (import-outside-toplevel)
mfa/Email.py:14:4: C0103: Variable name "User" doesn't conform to snake_case naming style (invalid-name)
mfa/Email.py:32:12: C0415: Import outside toplevel (django.http.HttpResponseRedirect) (import-outside-toplevel)
mfa/Email.py:35:12: W0702: No exception type(s) specified (bare-except)
mfa/Email.py:34:16: C0415: Import outside toplevel (django.core.urlresolvers.reverse) (import-outside-toplevel)
mfa/Email.py:36:16: C0415: Import outside toplevel (django.urls.reverse) (import-outside-toplevel)
mfa/Email.py:63:12: C0415: Import outside toplevel (django.utils.timezone) (import-outside-toplevel)
mfa/Email.py:4:0: C0411: standard import "import datetime, random" should be placed before "from django.shortcuts import render" (wrong-import-order)
mfa/Email.py:4:0: C0411: standard import "import datetime, random" should be placed before "from django.shortcuts import render" (wrong-import-order)
mfa/Email.py:5:0: C0411: standard import "from random import randint" should be placed before "from django.shortcuts import render" (wrong-import-order)
mfa/Email.py:6:0: W0614: Unused import(s) models, JSONField and jwt from wildcard import of models (unused-wildcard-import)
************* Module mfa.U2F
mfa/U2F.py:56:0: C0301: Line too long (114/100) (line-too-long)
mfa/U2F.py:63:0: C0301: Line too long (101/100) (line-too-long)
mfa/U2F.py:76:0: C0301: Line too long (114/100) (line-too-long)
mfa/U2F.py:85:0: C0301: Line too long (114/100) (line-too-long)
mfa/U2F.py:86:0: C0301: Line too long (110/100) (line-too-long)
mfa/U2F.py:107:0: C0301: Line too long (116/100) (line-too-long)
mfa/U2F.py:108:0: C0301: Line too long (137/100) (line-too-long)
mfa/U2F.py:110:0: C0301: Line too long (127/100) (line-too-long)
mfa/U2F.py:115:0: C0301: Line too long (108/100) (line-too-long)
mfa/U2F.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/U2F.py:1:0: C0103: Module name "U2F" doesn't conform to snake_case naming style (invalid-name)
mfa/U2F.py:13:0: W0401: Wildcard import models (wildcard-import)
mfa/U2F.py:19:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/U2F.py:28:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/U2F.py:30:7: C0121: Comparison 'x == True' should be 'x is True' if checking for the singleton value True, or 'x' if testing for truthiness (singleton-comparison)
mfa/U2F.py:31:8: C0415: Import outside toplevel (time) (import-outside-toplevel)
mfa/U2F.py:33:15: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/U2F.py:36:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/U2F.py:38:35: C0321: More than one statement on a single line (multiple-statements)
mfa/U2F.py:44:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/U2F.py:45:4: W0621: Redefining name 'datetime' from outer scope (line 16) (redefined-outer-name)
mfa/U2F.py:45:4: W0404: Reimport 'datetime' (imported line 16) (reimported)
mfa/U2F.py:45:4: C0415: Import outside toplevel (datetime, random) (import-outside-toplevel)
mfa/U2F.py:45:4: C0410: Multiple imports on one line (datetime, random) (multiple-imports)
mfa/U2F.py:50:7: C0121: Comparison 'res != True' should be 'res is not True' if checking for the singleton value True, or 'not res' if testing for falsiness (singleton-comparison)
mfa/U2F.py:66:4: W0702: No exception type(s) specified (bare-except)
mfa/U2F.py:56:74: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
mfa/U2F.py:54:12: W0612: Unused variable 'c' (unused-variable)
mfa/U2F.py:54:15: W0612: Unused variable 't' (unused-variable)
mfa/U2F.py:71:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/U2F.py:79:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/U2F.py:90:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/U2F.py:91:4: C0415: Import outside toplevel (hashlib) (import-outside-toplevel)
mfa/U2F.py:114:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/U2F.py:119:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/U2F.py:121:4: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/U2F.py:121:7: C0121: Comparison 'x == True' should be 'x is True' if checking for the singleton value True, or 'x' if testing for truthiness (singleton-comparison)
mfa/U2F.py:16:0: C0411: standard import "import datetime" should be placed before "from u2flib_server.u2f import begin_registration, begin_authentication, complete_registration, complete_authentication" (wrong-import-order)
mfa/U2F.py:17:0: C0411: third party import "from django.utils import timezone" should be placed before "from .models import *" (wrong-import-order)
mfa/U2F.py:10:0: C0412: Imports from package django are not grouped (ungrouped-imports)
mfa/U2F.py:16:0: W0611: Unused import datetime (unused-import)
mfa/U2F.py:13:0: W0614: Unused import(s) models, JSONField and jwt from wildcard import of models (unused-wildcard-import)
************* Module mfa.urls
mfa/urls.py:7:0: W0311: Bad indentation. Found 5 spaces, expected 4 (bad-indentation)
mfa/urls.py:56:0: C0304: Final newline missing (missing-final-newline)
mfa/urls.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/urls.py:6:0: W0702: No exception type(s) specified (bare-except)
************* Module mfa.helpers
mfa/helpers.py:23:0: C0301: Line too long (116/100) (line-too-long)
mfa/helpers.py:25:0: C0301: Line too long (118/100) (line-too-long)
mfa/helpers.py:27:0: C0301: Line too long (120/100) (line-too-long)
mfa/helpers.py:29:0: C0301: Line too long (119/100) (line-too-long)
mfa/helpers.py:32:0: C0305: Trailing newlines (trailing-newlines)
mfa/helpers.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/helpers.py:2:0: W0401: Wildcard import models (wildcard-import)
mfa/helpers.py:7:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/helpers.py:12:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/helpers.py:12:0: W0102: Dangerous default value [] as argument (dangerous-default-value)
mfa/helpers.py:18:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/helpers.py:21:15: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/helpers.py:22:4: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
mfa/helpers.py:23:15: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/helpers.py:25:15: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/helpers.py:27:15: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/helpers.py:29:15: R5102: Instead of HttpResponse(content_type='application/json') use JsonResponse() (http-response-with-content-type-json)
mfa/helpers.py:18:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
mfa/helpers.py:4:0: C0411: third party import "import simplejson" should be placed before "from .models import *" (wrong-import-order)
mfa/helpers.py:5:0: C0411: third party import "from django.shortcuts import HttpResponse" should be placed before "from .models import *" (wrong-import-order)
mfa/helpers.py:6:0: C0411: first party import "from mfa.views import verify, goto" should be placed before "from .models import *" (wrong-import-order)
mfa/helpers.py:1:0: W0611: Unused import pyotp (unused-import)
mfa/helpers.py:6:0: W0611: Unused goto imported from mfa.views (unused-import)
mfa/helpers.py:2:0: W0614: Unused import(s) models, JSONField, jwt and settings from wildcard import of models (unused-wildcard-import)
************* Module mfa.middleware
mfa/middleware.py:12:0: C0301: Line too long (117/100) (line-too-long)
mfa/middleware.py:13:0: C0304: Final newline missing (missing-final-newline)
mfa/middleware.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/middleware.py:3:0: E0401: Unable to import 'django.core.urlresolvers' (import-error)
mfa/middleware.py:3:0: E0611: No name 'urlresolvers' in module 'django.core' (no-name-in-module)
mfa/middleware.py:5:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/middleware.py:7:23: C0321: More than one statement on a single line (multiple-statements)
mfa/middleware.py:12:60: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
************* Module mfa.views
mfa/views.py:20:0: C0301: Line too long (134/100) (line-too-long)
mfa/views.py:21:0: C0301: Line too long (128/100) (line-too-long)
mfa/views.py:56:0: C0301: Line too long (113/100) (line-too-long)
mfa/views.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/views.py:5:0: W0401: Wildcard import models (wildcard-import)
mfa/views.py:8:0: W0702: No exception type(s) specified (bare-except)
mfa/views.py:18:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/views.py:35:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/views.py:39:17: R1718: Consider using a set comprehension (consider-using-set-comprehension)
mfa/views.py:55:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/views.py:58:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/views.py:63:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/views.py:65:4: W0621: Redefining name 'settings' from outer scope (line 5) (redefined-outer-name)
mfa/views.py:64:4: C0415: Import outside toplevel (django.contrib.auth) (import-outside-toplevel)
mfa/views.py:65:4: W0404: Reimport 'settings' (imported line 12) (reimported)
mfa/views.py:65:4: C0415: Import outside toplevel (django.conf.settings) (import-outside-toplevel)
mfa/views.py:64:4: W0611: Unused auth imported from django.contrib (unused-import)
mfa/views.py:71:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/views.py:71:0: C0103: Function name "delKey" doesn't conform to snake_case naming style (invalid-name)
mfa/views.py:73:4: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/views.py:80:4: W0621: Redefining name 'importlib' from outer scope (line 1) (redefined-outer-name)
mfa/views.py:80:4: W0404: Reimport 'importlib' (imported line 1) (reimported)
mfa/views.py:80:4: C0415: Import outside toplevel (importlib) (import-outside-toplevel)
mfa/views.py:82:8: W0719: Raising too general exception: Exception (broad-exception-raised)
mfa/views.py:89:8: W0719: Raising too general exception: Exception (broad-exception-raised)
mfa/views.py:93:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/views.py:93:0: C0103: Function name "toggleKey" doesn't conform to snake_case naming style (invalid-name)
mfa/views.py:94:4: W0622: Redefining built-in 'id' (redefined-builtin)
mfa/views.py:98:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
mfa/views.py:107:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/views.py:10:0: C0411: third party import "from django.template.context_processors import csrf" should be placed before "from .models import *" (wrong-import-order)
mfa/views.py:11:0: C0411: third party import "from django.template.context import RequestContext" should be placed before "from .models import *" (wrong-import-order)
mfa/views.py:12:0: C0411: third party import "from django.conf import settings" should be placed before "from .models import *" (wrong-import-order)
mfa/views.py:14:0: C0411: third party import "from django.contrib.auth.decorators import login_required" should be placed before "from .models import *" (wrong-import-order)
mfa/views.py:15:0: C0411: third party import "from user_agents import parse" should be placed before "from .models import *" (wrong-import-order)
mfa/views.py:1:0: W0611: Unused import importlib (unused-import)
mfa/views.py:10:0: W0611: Unused csrf imported from django.template.context_processors (unused-import)
mfa/views.py:11:0: W0611: Unused RequestContext imported from django.template.context (unused-import)
mfa/views.py:5:0: W0614: Unused import(s) models, JSONField and jwt from wildcard import of models (unused-wildcard-import)
************* Module mfa.migrations.0010_auto_20201110_0557
mfa/migrations/0010_auto_20201110_0557.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0010_auto_20201110_0557.py:1:0: C0103: Module name "0010_auto_20201110_0557" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0010_auto_20201110_0557.py:6:0: C0115: Missing class docstring (missing-class-docstring)
************* Module mfa.migrations.0006_trusted_devices
mfa/migrations/0006_trusted_devices.py:17:0: C0301: Line too long (114/100) (line-too-long)
mfa/migrations/0006_trusted_devices.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0006_trusted_devices.py:1:0: C0103: Module name "0006_trusted_devices" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0006_trusted_devices.py:7:0: C0115: Missing class docstring (missing-class-docstring)
************* Module mfa.migrations.0005_auto_20181115_2014
mfa/migrations/0005_auto_20181115_2014.py:11:0: C0301: Line too long (108/100) (line-too-long)
mfa/migrations/0005_auto_20181115_2014.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0005_auto_20181115_2014.py:1:0: C0103: Module name "0005_auto_20181115_2014" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0005_auto_20181115_2014.py:11:8: W0707: Consider explicitly re-raising using 'except ImportError as exc' and 'raise ImportError("Can't find a JSONField implementation, please install jsonfield if django < 4.0") from exc' (raise-missing-from)
mfa/migrations/0005_auto_20181115_2014.py:15:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/migrations/0005_auto_20181115_2014.py:16:4: C0415: Import outside toplevel (django.conf.settings) (import-outside-toplevel)
mfa/migrations/0005_auto_20181115_2014.py:15:16: W0613: Unused argument 'apps' (unused-argument)
mfa/migrations/0005_auto_20181115_2014.py:15:22: W0613: Unused argument 'schema_editor' (unused-argument)
mfa/migrations/0005_auto_20181115_2014.py:21:0: C0115: Missing class docstring (missing-class-docstring)
mfa/migrations/0005_auto_20181115_2014.py:4:0: W0611: Unused models imported from django.db (unused-import)
************* Module mfa.migrations.0002_user_keys_key_type
mfa/migrations/0002_user_keys_key_type.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0002_user_keys_key_type.py:1:0: C0103: Module name "0002_user_keys_key_type" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0002_user_keys_key_type.py:7:0: C0115: Missing class docstring (missing-class-docstring)
************* Module mfa.migrations.0011_auto_20210530_0622
mfa/migrations/0011_auto_20210530_0622.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0011_auto_20210530_0622.py:1:0: C0103: Module name "0011_auto_20210530_0622" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0011_auto_20210530_0622.py:6:0: C0115: Missing class docstring (missing-class-docstring)
************* Module mfa.migrations.0007_auto_20181230_1549
mfa/migrations/0007_auto_20181230_1549.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0007_auto_20181230_1549.py:1:0: C0103: Module name "0007_auto_20181230_1549" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0007_auto_20181230_1549.py:7:0: C0115: Missing class docstring (missing-class-docstring)
************* Module mfa.migrations.0008_user_keys_last_used
mfa/migrations/0008_user_keys_last_used.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0008_user_keys_last_used.py:1:0: C0103: Module name "0008_user_keys_last_used" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0008_user_keys_last_used.py:7:0: C0115: Missing class docstring (missing-class-docstring)
************* Module mfa.migrations.0004_user_keys_enabled
mfa/migrations/0004_user_keys_enabled.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0004_user_keys_enabled.py:1:0: C0103: Module name "0004_user_keys_enabled" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0004_user_keys_enabled.py:7:0: C0115: Missing class docstring (missing-class-docstring)
************* Module mfa.migrations.0009_user_keys_owned_by_enterprise
mfa/migrations/0009_user_keys_owned_by_enterprise.py:10:0: C0301: Line too long (124/100) (line-too-long)
mfa/migrations/0009_user_keys_owned_by_enterprise.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0009_user_keys_owned_by_enterprise.py:1:0: C0103: Module name "0009_user_keys_owned_by_enterprise" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0009_user_keys_owned_by_enterprise.py:8:0: C0116: Missing function or method docstring (missing-function-docstring)
mfa/migrations/0009_user_keys_owned_by_enterprise.py:8:37: W0613: Unused argument 'schema_editor' (unused-argument)
mfa/migrations/0009_user_keys_owned_by_enterprise.py:13:0: C0115: Missing class docstring (missing-class-docstring)
************* Module mfa.migrations.0003_auto_20181114_2159
mfa/migrations/0003_auto_20181114_2159.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0003_auto_20181114_2159.py:1:0: C0103: Module name "0003_auto_20181114_2159" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0003_auto_20181114_2159.py:7:0: C0115: Missing class docstring (missing-class-docstring)
************* Module mfa.migrations.0001_initial
mfa/migrations/0001_initial.py:16:0: C0301: Line too long (114/100) (line-too-long)
mfa/migrations/0001_initial.py:1:0: C0114: Missing module docstring (missing-module-docstring)
mfa/migrations/0001_initial.py:1:0: C0103: Module name "0001_initial" doesn't conform to snake_case naming style (invalid-name)
mfa/migrations/0001_initial.py:7:0: C0115: Missing class docstring (missing-class-docstring)
mfa/migrations/0001_initial.py:1:0: R0801: Similar lines in 2 files
==mfa.U2F:[59:64]
==mfa.totp:[46:51]
        if getattr(settings, "MFA_RECHECK", False):
            mfa["next_check"] = datetime.datetime.timestamp((datetime.datetime.now()
                                     + datetime.timedelta(
                        seconds=random.randint(settings.MFA_RECHECK_MIN, settings.MFA_RECHECK_MAX))))
        request.session["mfa"] = mfa (duplicate-code)

------------------------------------------------------------------
Your code has been rated at 4.89/10 (previous run: 4.89/10, +0.00)
@oussjarrousse oussjarrousse changed the title Use pylint to ensure code quality - 5 errors were detected Use pylint to ensure code quality Jan 5, 2024
@oussjarrousse oussjarrousse changed the title Use pylint to ensure code quality Use pylint to ensure code quality - 5 errors were detected Jan 5, 2024
@oussjarrousse
Copy link
Author

@41WhiteElephants
Copy link

could you push a PR with pylint formatted files? Also a good idea would be to add a pre-commit config to run linters and formatters each time someone is doing a commit

mkalioby added a commit that referenced this issue Jan 23, 2024
@mkalioby
Copy link
Owner

mkalioby commented Jan 23, 2024

I added black as code style and pyre as type checker. Added missing requirements and added .pre-commit for both black & pyre
@41WhiteElephants and @oussjarrousse please check the branch and let me know.
The branch is https://github.com/mkalioby/django-mfa2/tree/black

@41WhiteElephants
Copy link

I'll take a look later today

@41WhiteElephants
Copy link

Looks better now but @mkalioby please remove all unused files and imports

@oussjarrousse
Copy link
Author

oussjarrousse commented Jan 24, 2024

I think what matters is to establish and enforce some "quality control" rules...
something like:

  • pull requests must be blacked
  • pull requests must pass pylint errors check
  • Fixing a bug means: adding a (regression) test that reproduces the bug, then fix the bug in source code, all tests including the new test must passes (that will ensure more coverage and no-reintroduction of old fixed bugs)

I wanted to mention that earlier in the "adding pytest" pull request but I was waiting for the dev to be merged with main. Once there is a way to run tests, you could automate running tests with actions and establish some rules regarding pull requests. Eventually you will see there is little need for the "dev" branch, and you will be using feature branches, tags, and releases. Patching bugs will be faster and publishing new versions will also be faster. The miracles that DevOps concepts brings from manufacturing sector to the IT world.

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

No branches or pull requests

3 participants