From 72226f289f61bea3b62e9a8d9c9953727e442f74 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 2 Aug 2021 23:10:51 -0300 Subject: [PATCH 1/3] Add configuration key maxComplexity to flake8 plugin This config key belongs to the flag used in flake8 to set MCcabe's threshold for complexity. --- pylsp/config/schema.json | 5 +++++ pylsp/plugins/flake8_lint.py | 1 + 2 files changed, 6 insertions(+) diff --git a/pylsp/config/schema.json b/pylsp/config/schema.json index d95db74a..75dc8a12 100644 --- a/pylsp/config/schema.json +++ b/pylsp/config/schema.json @@ -49,6 +49,11 @@ "default": null, "description": "List of errors and warnings to ignore (or skip)." }, + "pylsp.plugins.flake8.maxComplexity": { + "type": "integer", + "default": null, + "description": "Maximum allowed complexity threshold." + }, "pylsp.plugins.flake8.maxLineLength": { "type": "integer", "default": null, diff --git a/pylsp/plugins/flake8_lint.py b/pylsp/plugins/flake8_lint.py index 7ac8c622..98919d39 100644 --- a/pylsp/plugins/flake8_lint.py +++ b/pylsp/plugins/flake8_lint.py @@ -41,6 +41,7 @@ def pylsp_lint(workspace, document): 'filename': settings.get('filename'), 'hang-closing': settings.get('hangClosing'), 'ignore': ignores or None, + 'max-complexity': settings.get('maxComplexity'), 'max-line-length': settings.get('maxLineLength'), 'select': settings.get('select'), } From e9457bd5b61672ec0dcf13fb90af798481393b33 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 2 Aug 2021 23:13:10 -0300 Subject: [PATCH 2/3] Add documentation for new key in CONFIGURATION.md --- CONFIGURATION.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 46ab4adb..422592ab 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -11,6 +11,7 @@ This server can be configured using `workspace/didChangeConfiguration` method. E | `pylsp.plugins.flake8.filename` | `string` | Only check for filenames matching the patterns in this list. | `null` | | `pylsp.plugins.flake8.hangClosing` | `boolean` | Hang closing bracket instead of matching indentation of opening bracket's line. | `null` | | `pylsp.plugins.flake8.ignore` | `array` | List of errors and warnings to ignore (or skip). | `null` | +| `pylsp.plugins.flake8.maxComplexity` | `integer` | Maximum allowed complexity threshold. | `null` | | `pylsp.plugins.flake8.maxLineLength` | `integer` | Maximum allowed line length for the entirety of this run. | `null` | | `pylsp.plugins.flake8.perFileIgnores` | `array` | A pairing of filenames and violation codes that defines which violations to ignore in a particular file, for example: `["file_path.py:W305,W304"]`). | `null` | | `pylsp.plugins.flake8.select` | `array` | List of errors and warnings to enable. | `null` | From 56e2064a5126fb7146fdefe03c133c5ae0703182 Mon Sep 17 00:00:00 2001 From: Dionisio E Alonso Date: Mon, 2 Aug 2021 23:13:56 -0300 Subject: [PATCH 3/3] Add new key to config file reader for flake8 plugin --- pylsp/config/flake8_conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pylsp/config/flake8_conf.py b/pylsp/config/flake8_conf.py index eed9a31c..69cbf275 100644 --- a/pylsp/config/flake8_conf.py +++ b/pylsp/config/flake8_conf.py @@ -26,6 +26,7 @@ ('filename', 'plugins.flake8.filename', list), ('hang-closing', 'plugins.flake8.hangClosing', bool), ('ignore', 'plugins.flake8.ignore', list), + ('max-complexity', 'plugins.flake8.maxComplexity', int), ('max-line-length', 'plugins.flake8.maxLineLength', int), ('select', 'plugins.flake8.select', list), ('per-file-ignores', 'plugins.flake8.perFileIgnores', list),