diff options
| author | flip1995 <philipp.krones@embecosm.com> | 2021-07-01 18:17:38 +0200 |
|---|---|---|
| committer | flip1995 <philipp.krones@embecosm.com> | 2021-07-01 18:17:38 +0200 |
| commit | 1a385b80dca128bfc5c9fc4cfb0bc8e9f5a3ef07 (patch) | |
| tree | 79a5fb72746db0fe2833c57dc197c2dd85a77c47 /src/tools/clippy/util | |
| parent | 3cb1c1134050c059a15d9ca7a00d4dd89111a373 (diff) | |
| parent | 61eb38aeda6cb54b93b872bf503d70084c4d621c (diff) | |
| download | rust-1a385b80dca128bfc5c9fc4cfb0bc8e9f5a3ef07.tar.gz rust-1a385b80dca128bfc5c9fc4cfb0bc8e9f5a3ef07.zip | |
Merge commit '61eb38aeda6cb54b93b872bf503d70084c4d621c' into clippyup
Diffstat (limited to 'src/tools/clippy/util')
| -rwxr-xr-x | src/tools/clippy/util/etc/pre-commit.sh | 21 | ||||
| -rw-r--r-- | src/tools/clippy/util/etc/vscode-tasks.json | 57 | ||||
| -rw-r--r-- | src/tools/clippy/util/lintlib.py | 5 |
3 files changed, 81 insertions, 2 deletions
diff --git a/src/tools/clippy/util/etc/pre-commit.sh b/src/tools/clippy/util/etc/pre-commit.sh new file mode 100755 index 00000000000..528f8953b25 --- /dev/null +++ b/src/tools/clippy/util/etc/pre-commit.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# hide output +set -e + +# Update lints +cargo dev update_lints +git add clippy_lints/src/lib.rs + +# Formatting: +# Git will not automatically add the formatted code to the staged changes once +# fmt was executed. This collects all staged files rs files that are currently staged. +# They will later be added back. +# +# This was proudly stolen and adjusted from here: +# https://medium.com/@harshitbangar/automatic-code-formatting-with-git-66c3c5c26798 +files=$( (git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.rs$") || true) +if [ ! -z "${files}" ]; then + cargo dev fmt + git add $(echo "$files" | paste -s -d " " -) +fi diff --git a/src/tools/clippy/util/etc/vscode-tasks.json b/src/tools/clippy/util/etc/vscode-tasks.json new file mode 100644 index 00000000000..a4bb26b9f90 --- /dev/null +++ b/src/tools/clippy/util/etc/vscode-tasks.json @@ -0,0 +1,57 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "cargo check", + "type": "shell", + "command": "cargo check", + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true, + }, + }, + { + "label": "cargo dev fmt", + "type": "shell", + "command": "cargo dev fmt", + "problemMatcher": [], + "group": "none", + }, + { + "label": "cargo uitest", + "type": "shell", + "command": "cargo uitest", + "options": { + "env": { + "RUST_BACKTRACE": "1", + // This task will usually execute all UI tests inside `tests/ui` you can + // optionally uncomment the line below and only run a specific test. + // + // See: https://github.com/rust-lang/rust-clippy/blob/master/doc/adding_lints.md#testing + // + // "TESTNAME": "<TODO>", + }, + }, + "problemMatcher": [], + "group": { + "kind": "test", + "isDefault": true, + } + }, + { + "label": "cargo test", + "type": "shell", + "command": "cargo test", + "problemMatcher": [], + "group": "test", + }, + { + "label": "cargo dev bless", + "type": "shell", + "command": "cargo dev bless", + "problemMatcher": [], + "group": "none", + }, + ], +} diff --git a/src/tools/clippy/util/lintlib.py b/src/tools/clippy/util/lintlib.py index 5707cf0ce0f..9cefb2dbb19 100644 --- a/src/tools/clippy/util/lintlib.py +++ b/src/tools/clippy/util/lintlib.py @@ -12,13 +12,14 @@ Config = collections.namedtuple('Config', 'name ty doc default') lintname_re = re.compile(r'''pub\s+([A-Z_][A-Z_0-9]*)''') group_re = re.compile(r'''\s*([a-z_][a-z_0-9]+)''') -conf_re = re.compile(r'''define_Conf! {\n([^}]*)\n}''', re.MULTILINE) +conf_re = re.compile(r'''define_Conf! {\n((?!\n})[\s\S])*\n}''', re.MULTILINE) confvar_re = re.compile( r'''/// Lint: ([\w,\s]+)\. (.*)\n\s*\(([^:]+):\s*([^\s=]+)\s*=\s*([^\.\)]+).*\),''', re.MULTILINE) comment_re = re.compile(r'''\s*/// ?(.*)''') lint_levels = { "correctness": 'Deny', + "suspicious": 'Warn', "style": 'Warn', "complexity": 'Warn', "perf": 'Warn', @@ -91,7 +92,7 @@ def parse_configs(path): contents = fp.read() match = re.search(conf_re, contents) - confvars = re.findall(confvar_re, match.group(1)) + confvars = re.findall(confvar_re, match.group(0)) for (lints, doc, name, ty, default) in confvars: for lint in lints.split(','): |
