Skip to content

Commit b4508d5

Browse files
committed
Add exclude configuration
1 parent 04733cd commit b4508d5

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Installation
66

7-
[checkpatch.pl](https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl) script should be installed on your machine. It should be either exposed through $PATH or
7+
[checkpatch.pl](https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl) script should be either exposed through $PATH or
88
pointed out by the `checkpatch.checkpatchPath` configuration.
99

1010
### Linux / [WSL Remote Development](https://code.visualstudio.com/docs/remote/wsl)
@@ -22,15 +22,17 @@ cmd as administrator:
2222
curl -o %WINDIR%/System32/checkpatch.pl "https://raw.githubusercontent.com/torvalds/linux/master/scripts/checkpatch.pl"
2323
curl -o %WINDIR%/System32/spelling.txt "https://raw.githubusercontent.com/torvalds/linux/master/scripts/spelling.txt"
2424
```
25-
Additionally, a perl interpreter should also be installed - tested with [ActivePerl Community Edition](https://www.activestate.com/products/activeperl/downloads/).
25+
On windows, a perl interpreter should also be installed - tested with [ActivePerl Community Edition](https://www.activestate.com/products/activeperl/downloads/).
2626
*.pl files should be configured to be opened by the interpreter by default (double click on any *.pl file and choose ActivePerl as the default program).
2727
GNU 'diff' executable should also be available (can be done by installing [git-for-windows](https://git-scm.com/download/win) and adding it to PATH).
2828

2929
## Commands
3030
* `checkpatch.checkFile` Check selected file (if the run mode is manual)
3131
* `checkpatch.checkCommit` Select specific commit to be tested
32-
* `checkpatch.toggleAutoRun` Toggle checkpatch for the current workspace
32+
* `checkpatch.toggleAutoRun` Toggle automatic checkpatch for the current workspace
3333

3434
## settings.json
35-
* `checkpatch.checkpatchArgs` let you add arguments such as `--ignore BLOCK_COMMENT_STYLE`, `--max-line-length=120`
36-
* `checkpatch.run` control whether the linting is automatic or manually triggered using the `checkpatch.checkFile` command.
35+
* `checkpatch.checkpatchPath` path to the checkpatch.pl script
36+
* `checkpatch.checkpatchArgs` checkpatch arguments to use
37+
* `checkpatch.run` control whether the linting is automatic on save or manually triggered using the `checkpatch.checkFile` command.
38+
* `checkpatch.exclude` Glob patterns for excluding files and folders from automatic checks.

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"checkpatch.checkpatchPath": {
3636
"type": "string",
3737
"default": "checkpatch.pl",
38-
"description": "Path to the checkpatch script"
38+
"description": "Path to the checkpatch.pl script"
3939
},
4040
"checkpatch.checkpatchArgs": {
4141
"type": "array",
@@ -52,6 +52,11 @@
5252
],
5353
"default": "onSave",
5454
"description": "Whether the linter is run automatically on save or manually."
55+
},
56+
"checkpatch.exclude": {
57+
"type": "array",
58+
"default": [],
59+
"description": "Glob patterns for excluding files and folders from automatic checks."
5560
}
5661
}
5762
},
@@ -124,5 +129,8 @@
124129
},
125130
"extensionDependencies": [
126131
"vscode.git"
127-
]
132+
],
133+
"dependencies": {
134+
"minimatch": "^3.0.3"
135+
}
128136
}

src/checkpatchProvider.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
import * as cp from 'child_process';
33
import * as path from 'path';
44
import * as vscode from 'vscode';
5+
import * as minimatch from 'minimatch';
56
import { GitExtension, API as GitAPI, Repository, } from './typings/git';
67

78
export interface LinterConfig {
89
path: string;
910
args: string[];
11+
excludeGlobs: string[];
1012
}
1113

1214
interface RepoPickItem extends vscode.QuickPickItem {
@@ -55,6 +57,7 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
5557
this.linterConfig = {
5658
path: config.checkpatchPath,
5759
args: config.checkpatchArgs,
60+
excludeGlobs: config.exclude,
5861
};
5962

6063
if (this.documentListener) {
@@ -124,6 +127,11 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
124127
if (textDocument.languageId !== 'c') {
125128
return;
126129
}
130+
for (var excludeGlob of this.linterConfig.excludeGlobs) {
131+
if (minimatch(textDocument.fileName, excludeGlob)) {
132+
return;
133+
}
134+
}
127135

128136
let log = '';
129137
let args = this.linterConfig.args.slice();

0 commit comments

Comments
 (0)