diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 9429bc6..0000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,187 +0,0 @@ -env: - browser: true - es6: true - -# See https://github.com/OCA/odoo-community.org/issues/37#issuecomment-470686449 -parserOptions: - ecmaVersion: 2019 - -overrides: - - files: - - "**/*.esm.js" - parserOptions: - sourceType: module - -# Globals available in Odoo that shouldn't produce errorings -globals: - _: readonly - $: readonly - fuzzy: readonly - jQuery: readonly - moment: readonly - odoo: readonly - openerp: readonly - owl: readonly - -# Styling is handled by Prettier, so we only need to enable AST rules; -# see https://github.com/OCA/maintainer-quality-tools/pull/618#issuecomment-558576890 -rules: - accessor-pairs: warn - array-callback-return: warn - callback-return: warn - capitalized-comments: - - warn - - always - - ignoreConsecutiveComments: true - ignoreInlineComments: true - complexity: - - warn - - 15 - constructor-super: warn - dot-notation: warn - eqeqeq: warn - global-require: warn - handle-callback-err: warn - id-blacklist: warn - id-match: warn - init-declarations: error - max-depth: warn - max-nested-callbacks: warn - max-statements-per-line: warn - no-alert: warn - no-array-constructor: warn - no-caller: warn - no-case-declarations: warn - no-class-assign: warn - no-cond-assign: error - no-const-assign: error - no-constant-condition: warn - no-control-regex: warn - no-debugger: error - no-delete-var: warn - no-div-regex: warn - no-dupe-args: error - no-dupe-class-members: error - no-dupe-keys: error - no-duplicate-case: error - no-duplicate-imports: error - no-else-return: warn - no-empty-character-class: warn - no-empty-function: error - no-empty-pattern: error - no-empty: warn - no-eq-null: error - no-eval: error - no-ex-assign: error - no-extend-native: warn - no-extra-bind: warn - no-extra-boolean-cast: warn - no-extra-label: warn - no-fallthrough: warn - no-func-assign: error - no-global-assign: error - no-implicit-coercion: - - warn - - allow: ["~"] - no-implicit-globals: warn - no-implied-eval: warn - no-inline-comments: warn - no-inner-declarations: warn - no-invalid-regexp: warn - no-irregular-whitespace: warn - no-iterator: warn - no-label-var: warn - no-labels: warn - no-lone-blocks: warn - no-lonely-if: error - no-mixed-requires: error - no-multi-str: warn - no-native-reassign: error - no-negated-condition: warn - no-negated-in-lhs: error - no-new-func: warn - no-new-object: warn - no-new-require: warn - no-new-symbol: warn - no-new-wrappers: warn - no-new: warn - no-obj-calls: warn - no-octal-escape: warn - no-octal: warn - no-param-reassign: warn - no-path-concat: warn - no-process-env: warn - no-process-exit: warn - no-proto: warn - no-prototype-builtins: warn - no-redeclare: warn - no-regex-spaces: warn - no-restricted-globals: warn - no-restricted-imports: warn - no-restricted-modules: warn - no-restricted-syntax: warn - no-return-assign: error - no-script-url: warn - no-self-assign: warn - no-self-compare: warn - no-sequences: warn - no-shadow-restricted-names: warn - no-shadow: warn - no-sparse-arrays: warn - no-sync: warn - no-this-before-super: warn - no-throw-literal: warn - no-undef-init: warn - no-undef: error - no-unmodified-loop-condition: warn - no-unneeded-ternary: error - no-unreachable: error - no-unsafe-finally: error - no-unused-expressions: error - no-unused-labels: error - no-unused-vars: error - no-use-before-define: error - no-useless-call: warn - no-useless-computed-key: warn - no-useless-concat: warn - no-useless-constructor: warn - no-useless-escape: warn - no-useless-rename: warn - no-void: warn - no-with: warn - operator-assignment: [error, always] - prefer-const: warn - radix: warn - require-yield: warn - sort-imports: warn - spaced-comment: [error, always] - strict: [error, function] - use-isnan: error - valid-jsdoc: - - warn - - prefer: - arg: param - argument: param - augments: extends - constructor: class - exception: throws - func: function - method: function - prop: property - return: returns - virtual: abstract - yield: yields - preferType: - array: Array - bool: Boolean - boolean: Boolean - number: Number - object: Object - str: String - string: String - requireParamDescription: false - requireReturn: false - requireReturnDescription: false - requireReturnType: false - valid-typeof: warn - yoda: warn diff --git a/.flake8 b/.flake8 deleted file mode 100644 index d68c5f9..0000000 --- a/.flake8 +++ /dev/null @@ -1,13 +0,0 @@ -[flake8] -max-line-length = 88 -max-complexity = 16 -# B = bugbear -# B9 = bugbear opinionated (incl line length) -select = C,E,F,W,B,B9 -# E203: whitespace before ':' (black behaviour) -# E501: flake8 line length (covered by bugbear B950) -# W503: line break before binary operator (black behaviour) -ignore = E203,E501,W503 -per-file-ignores= - __init__.py:F401 - auto_texts.py:B950 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 03cfdda..e2336b8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,6 +11,8 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.0 + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.12" + - uses: pre-commit/action@v3.0.0 diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 0ec187e..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,13 +0,0 @@ -[settings] -; see https://github.com/psf/black -multi_line_output=3 -include_trailing_comma=True -force_grid_wrap=0 -combine_as_imports=True -use_parentheses=True -line_length=88 -known_odoo=odoo -known_odoo_addons=odoo.addons -sections=FUTURE,STDLIB,THIRDPARTY,ODOO,ODOO_ADDONS,FIRSTPARTY,LOCALFOLDER -default_section=THIRDPARTY -ensure_newline_before_comments = True diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 575b6a7..95fb195 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,24 +1,4 @@ -exclude: | - (?x) - # NOT INSTALLABLE ADDONS - # END NOT INSTALLABLE ADDONS - # Files and folders generated by bots, to avoid loops - ^setup/|/static/description/index\.html$| - # We don't want to mess with tool-generated files - .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/| - # Maybe reactivate this when all README files include prettier ignore tags? - ^README\.md$| - # Library files can have extraneous formatting (even minimized) - /static/(src/)?lib/| - # Repos using Sphinx to generate docs don't need prettying - ^docs/_templates/.*\.html$| - # You don't usually want a bot to modify your legal texts - (LICENSE.*|COPYING.*) repos: - - repo: https://github.com/psf/black - rev: 22.3.0 - hooks: - - id: black - repo: https://github.com/pre-commit/mirrors-prettier rev: v2.4.1 hooks: @@ -26,7 +6,7 @@ repos: # https://github.com/prettier/prettier/issues/12143 exclude: "}$" - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.5.0 hooks: - id: check-case-conflict - id: check-docstring-first @@ -41,16 +21,9 @@ repos: - id: mixed-line-ending args: ["--fix=lf"] - id: trailing-whitespace - - repo: https://github.com/pycqa/flake8 - rev: 3.9.2 - hooks: - - id: flake8 - additional_dependencies: ["flake8-bugbear==21.9.2"] - - repo: https://github.com/asottile/pyupgrade - rev: v2.29.0 - hooks: - - id: pyupgrade - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.3 hooks: - - id: isort + - id: ruff + args: [--exit-non-zero-on-fix] + - id: ruff-format diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..1a89f9e --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,41 @@ +- id: oca-gen-addon-readme + name: Generate addons README files from fragments + always_run: true + entry: oca-gen-addon-readme + language: python + pass_filenames: false + +- id: oca-gen-addons-table + name: Generate addons table in README + always_run: true + entry: oca-gen-addons-table + language: python + pass_filenames: false + +- id: oca-gen-addon-icon + name: Generate addons icons + always_run: true + entry: oca-gen-addon-icon + language: python + pass_filenames: false + +- id: oca-update-pre-commit-excluded-addons + name: Update pre-commit excluded addons + entry: oca-update-pre-commit-excluded-addons + pass_filenames: false + language: python + always_run: true + +- id: oca-fix-manifest-website + name: Fix the manifest website key + entry: oca-fix-manifest-website + pass_filenames: false + language: python + files: (__manifest__\.py|__openerp__\.py|__terp__\.py)$ + +- id: oca-gen-external-dependencies + name: Generate requirements.txt for an addons directory + entry: oca-gen-external-dependencies + language: python + pass_filenames: false + files: (__manifest__\.py|__openerp__\.py|__terp__\.py|setup\.py|pyproject\.toml)$ diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index d1f7297..0000000 --- a/.pylintrc +++ /dev/null @@ -1,90 +0,0 @@ - - -[MASTER] -load-plugins=pylint_odoo -score=n - -[ODOOLINT] -readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" -manifest_required_authors=Odoo Community Association (OCA) -manifest_required_keys=license -manifest_deprecated_keys=description,active -license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 -valid_odoo_versions=14.0 - -[MESSAGES CONTROL] -disable=all - -# This .pylintrc contains optional AND mandatory checks and is meant to be -# loaded in an IDE to have it check everything, in the hope this will make -# optional checks more visible to contributors who otherwise never look at a -# green travis to see optional checks that failed. -# .pylintrc-mandatory containing only mandatory checks is used the pre-commit -# config as a blocking check. - -enable=anomalous-backslash-in-string, - api-one-deprecated, - api-one-multi-together, - assignment-from-none, - attribute-deprecated, - class-camelcase, - dangerous-default-value, - dangerous-view-replace-wo-priority, - development-status-allowed, - duplicate-id-csv, - duplicate-key, - duplicate-xml-fields, - duplicate-xml-record-id, - eval-referenced, - eval-used, - incoherent-interpreter-exec-perm, - license-allowed, - manifest-author-string, - manifest-deprecated-key, - manifest-required-author, - manifest-required-key, - manifest-version-format, - method-compute, - method-inverse, - method-required-super, - method-search, - openerp-exception-warning, - pointless-statement, - pointless-string-statement, - print-used, - redundant-keyword-arg, - redundant-modulename-xml, - reimported, - relative-import, - return-in-init, - rst-syntax-error, - sql-injection, - too-few-format-args, - translation-field, - translation-required, - unreachable, - use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error, - # messages that do not cause the lint step to fail - consider-merging-classes-inherited, - create-user-wo-reset-password, - dangerous-filter-wo-user, - deprecated-module, - file-not-used, - invalid-commit, - missing-manifest-dependency, - missing-newline-extrafiles, - missing-readme, - no-utf8-coding-comment, - odoo-addons-relative-import, - old-api7-method-defined, - redefined-builtin, - too-complex, - unnecessary-utf8-coding-comment - - -[REPORTS] -msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} -output-format=colorized -reports=no diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory deleted file mode 100644 index 3bf8cee..0000000 --- a/.pylintrc-mandatory +++ /dev/null @@ -1,65 +0,0 @@ - -[MASTER] -load-plugins=pylint_odoo -score=n - -[ODOOLINT] -readme_template_url="https://github.com/OCA/maintainer-tools/blob/master/template/module/README.rst" -manifest_required_authors=Odoo Community Association (OCA) -manifest_required_keys=license -manifest_deprecated_keys=description,active -license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3 -valid_odoo_versions=14.0 - -[MESSAGES CONTROL] -disable=all - -enable=anomalous-backslash-in-string, - api-one-deprecated, - api-one-multi-together, - assignment-from-none, - attribute-deprecated, - class-camelcase, - dangerous-default-value, - dangerous-view-replace-wo-priority, - development-status-allowed, - duplicate-id-csv, - duplicate-key, - duplicate-xml-fields, - duplicate-xml-record-id, - eval-referenced, - eval-used, - incoherent-interpreter-exec-perm, - license-allowed, - manifest-author-string, - manifest-deprecated-key, - manifest-required-author, - manifest-required-key, - manifest-version-format, - method-compute, - method-inverse, - method-required-super, - method-search, - openerp-exception-warning, - pointless-statement, - pointless-string-statement, - print-used, - redundant-keyword-arg, - redundant-modulename-xml, - reimported, - relative-import, - return-in-init, - rst-syntax-error, - sql-injection, - too-few-format-args, - translation-field, - translation-required, - unreachable, - use-vim-comment, - wrong-tabs-instead-of-spaces, - xml-syntax-error - -[REPORTS] -msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} -output-format=colorized -reports=no diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..a484d01 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,29 @@ +target-version = "py38" +fix = true + +[lint] +extend-select = [ + "B", + "C90", + "E501", # line too long (default 88) + "I", # isort + "UP", # pyupgrade +] +exclude = ["setup/*"] + +[format] +exclude = ["setup/*"] + +[per-file-ignores] +"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py +"__manifest__.py" = ["B018"] # useless expression + +[isort] +section-order = ["future", "standard-library", "third-party", "odoo", "odoo-addons", "first-party", "local-folder"] + +[isort.sections] +"odoo" = ["odoo"] +"odoo-addons" = ["odoo.addons"] + +[mccabe] +max-complexity = 16 diff --git a/.sonarcloud.properties b/.sonarcloud.properties index 5ea75c6..b81d8d7 100644 --- a/.sonarcloud.properties +++ b/.sonarcloud.properties @@ -1,2 +1,2 @@ # Exclude files or directories -sonar.exclusions=**/__manifest__.py,**/thank_you_quote_template.html +sonar.exclusions=**/__manifest__.py,**/thank_you_quote_template.html,**description/index.html diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b07b4e0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -language: python - -python: - - "3.6" - -sudo: false -cache: pip - -addons: - postgresql: "9.6" - apt: - packages: - - expect-dev # provides unbuffer utility - - libcups2-dev # otherwise travis fails to install pycups - - postgresql-9.6-postgis-2.3 # travis doesn't know which one to install - - postgresql-9.6-postgis-2.3-scripts # pre-installed on travis but required for runbot - - libzbar0 # for pyzbar to work - - tesseract-ocr # used by pytesseract - - tesseract-ocr-eng - - tesseract-ocr-fra - - tesseract-ocr-deu - - tesseract-ocr-ita - - tesseract-ocr-spa -env: - global: - - VERSION="12.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0" - - matrix: - - LINT_CHECK="1" - - TESTS="1" ODOO_REPO="odoo/odoo" - -install: - - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git - ${HOME}/maintainer-quality-tools - - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - - travis_install_nightly - - printf '[options]\n\nrunning_env = dev\n' > ${HOME}/.openerp_serverrc - -before_script: - - psql -U postgres -d postgres -c "create extension postgis" - - psql -U postgres -d postgres -c "create extension postgis_topology" - -script: - - travis_run_tests - -after_success: - - travis_after_tests_success - -coverage: - status: - project: - default: - # basic - target: 40% - threshold: 1% diff --git a/my_compassion/controllers/auto_texts.py b/my_compassion/controllers/auto_texts.py index 8501f6e..5cd8182 100644 --- a/my_compassion/controllers/auto_texts.py +++ b/my_compassion/controllers/auto_texts.py @@ -1,3 +1,4 @@ +# ruff: noqa: E501 CHRISTMAS_TEXTS = { "fra": """Bonjour %s, diff --git a/my_compassion/controllers/my_account.py b/my_compassion/controllers/my_account.py index 618b6b5..ae9e957 100644 --- a/my_compassion/controllers/my_account.py +++ b/my_compassion/controllers/my_account.py @@ -107,7 +107,7 @@ def _create_archive(images, archive_name): """ base_url = request.httprequest.host_url with ZipFile(archive_name, "w") as archive: - for (img, full_path) in images: + for img, full_path in images: filename = path.basename(full_path) # Create file, write to archive and delete it from os @@ -513,7 +513,7 @@ def my_donations(self, invoice_page=1, invoice_per_page=12, **kw): # {group: (, total_amount string), ...} sponsorships_by_group = { g: ( - sponsorships.filtered(lambda s: s.group_id == g), + sponsorships.filtered(lambda s, g=g: s.group_id == g), f"{int(g.total_amount):,d} {currency}", ) for g in sponsorships.mapped("group_id") diff --git a/my_compassion/static/src/js/write_a_letter.js b/my_compassion/static/src/js/write_a_letter.js index 1daa027..a5a4a50 100644 --- a/my_compassion/static/src/js/write_a_letter.js +++ b/my_compassion/static/src/js/write_a_letter.js @@ -155,12 +155,10 @@ function removeImage(name, size, type) { */ function displayImages() { // We use the images stored in the new_images array - for (let i = 0; i < new_images.length; i++) { - const original_image = new_images[i]; - + new_images.forEach(original_image => { if (original_image.size > hard_max_size_limit) { displayAlert("image_too_large"); - continue; + return; } const reader = new FileReader(); @@ -202,7 +200,7 @@ function displayImages() { }; }; reader.readAsDataURL(original_image); - } + }); new_images = []; } diff --git a/theme_compassion/__manifest__.py b/theme_compassion/__manifest__.py index 616f664..38ccd31 100644 --- a/theme_compassion/__manifest__.py +++ b/theme_compassion/__manifest__.py @@ -1,18 +1,16 @@ { - 'name': 'Compassion Theme', - 'description': 'Compassion Blue Theme', - 'category': 'Theme/Services', - 'summary': 'Compassion Blue Theme', - 'sequence': 260, - 'version': '1.0.0', - 'author': 'Compassion CH', - 'depends': ['website'], - 'data': [ - 'views/assets.xml', - 'views/images_content.xml', + "name": "Compassion Theme", + "description": "Compassion Blue Theme", + "category": "Theme/Services", + "summary": "Compassion Blue Theme", + "sequence": 260, + "version": "1.0.0", + "author": "Compassion CH", + "depends": ["website"], + "data": [ + "views/assets.xml", + "views/images_content.xml", ], - 'images': [ - 'static/description/compassion_screenshot.jpeg' - ], - 'license': 'LGPL-3', + "images": ["static/description/compassion_screenshot.jpeg"], + "license": "LGPL-3", } diff --git a/theme_compassion/static/src/scss/primary_variables.scss b/theme_compassion/static/src/scss/primary_variables.scss index 6c0628f..d7be4fd 100644 --- a/theme_compassion/static/src/scss/primary_variables.scss +++ b/theme_compassion/static/src/scss/primary_variables.scss @@ -1,20 +1,18 @@ - //------------------------------------------------------------------------------ // Colors //------------------------------------------------------------------------------ // Colors $o-color-palettes: ( - ( - 'o-color-1': #0054a6, - 'o-color-2': #79a0c6, - 'o-color-3': #f5f5f5, - 'o-color-4': #ffffff, - 'o-color-5': #111111, - - 'footer': 4, - 'copyright': 4, - ), + ( + "o-color-1": #0054a6, + "o-color-2": #79a0c6, + "o-color-3": #f5f5f5, + "o-color-4": #ffffff, + "o-color-5": #111111, + "footer": 4, + "copyright": 4, + ) ); //------------------------------------------------------------------------------ @@ -29,10 +27,13 @@ $o-theme-h5-font-size-multiplier: 1; $o-theme-h6-font-size-multiplier: (12 / 14); $o-theme-font-configs: ( - 'Montserrat': ( - 'family': ('Montserrat', cursive), - 'url': 'Montserrat:300,300i,400,400i,700,700i', + "Montserrat": ( + "family": ( + "Montserrat", + cursive, ), + "url": "Montserrat:300,300i,400,400i,700,700i", + ), ); //------------------------------------------------------------------------------ @@ -40,25 +41,26 @@ $o-theme-font-configs: ( //------------------------------------------------------------------------------ $o-website-values-palettes: ( - ( - 'header-font-size': (18 / 16) * 1rem, - 'font': 'Roboto', - 'headings-font': 'Montserrat', - 'navbar-font': 'Montserrat', - 'buttons-font': 'Montserrat', - 'header-template': 'hamburger', - 'hamburger-type': 'off-canvas', - 'hamburger-position': 'left', - 'footer-template': 'links', - - 'btn-border-radius': 0, - 'btn-border-radius-sm': 0, - 'btn-border-radius-lg': 0, - 'btn-font-size': 1.2rem, - 'btn-padding-y': .474rem, - 'btn-padding-x': 1.25rem, - 'btn-font-size-lg': 2rem, - 'btn-padding-y-lg': .4rem, - 'btn-padding-x-lg': 2rem, - ), + ( + "header-font-size": ( + 18 / 16, + ) * 1rem, + "font": "Roboto", + "headings-font": "Montserrat", + "navbar-font": "Montserrat", + "buttons-font": "Montserrat", + "header-template": "hamburger", + "hamburger-type": "off-canvas", + "hamburger-position": "left", + "footer-template": "links", + "btn-border-radius": 0, + "btn-border-radius-sm": 0, + "btn-border-radius-lg": 0, + "btn-font-size": 1.2rem, + "btn-padding-y": 0.474rem, + "btn-padding-x": 1.25rem, + "btn-font-size-lg": 2rem, + "btn-padding-y-lg": 0.4rem, + "btn-padding-x-lg": 2rem, + ) ); diff --git a/website_child_protection/static/description/index.html b/website_child_protection/static/description/index.html index c513fbb..761bf28 100644 --- a/website_child_protection/static/description/index.html +++ b/website_child_protection/static/description/index.html @@ -3,10 +3,7 @@ - + Website - Child protection agreement