Skip to content

Commit 5a835c4

Browse files
committed
Add user control for the maximum number of files to analyze
1 parent a4429d7 commit 5a835c4

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ This linter plugin for [SublimeLinter](https://github.com/SublimeLinter) provide
1616

1717
In order for `golangci-lint` to be executed by SublimeLinter, you must ensure that its path is available to SublimeLinter. Before going any further, please read and follow the steps in [Finding a linter executable](http://sublimelinter.readthedocs.org/en/latest/troubleshooting.html#finding-a-linter-executable) through “Validating your PATH” in the documentation. Once you have installed `golangci-lint`, you can proceed to install the plugin if it is not yet installed.
1818

19+
Due to performance issues in golangci-lint, the linter will not attempt to lint more than one-hundred (100) files considering a delay of 100ms and `lint_mode` equal to “background”. If the user increases the delay, the tool will have more time to scan more files and analyze them. If your project contains more than 300 files, you’ll have to set a delay of 0.3s or more in SublimeLinter settings.
20+
1921
**Note:** The linter creates a temporary directory to allow SublimeLinter to scan changes in the code that are still in the buffer _(aka. not saved yet)_. If the SublimeText sidebar is visible, you will notice _—for a split of a second—_ that a folder named `.golangcilint-*` appears and disappears. Make sure to add this folder to your `.gitignore` file, and also the “folder_exclude_patterns” in SublimeText’s preferences:
2022

2123
```

linter.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88

99
logger = logging.getLogger('SublimeLinter.plugin.golangcilint')
1010

11-
# Due to performance issues in golangci-lint, the linter will not attempt to
12-
# lint a maximum of one-hundred (100) files considering a delay of 100ms and
13-
# lint_mode equal to “background”. If the user increases the delay, the tool
14-
# will have more time to scan more files and analyze them.
15-
MAX_FILES = 100
1611

1712
class Golangcilint(NodeLinter):
1813
cmd = "golangci-lint run --fast --out-format json"
@@ -99,9 +94,15 @@ def _foreground_lint(self, cmd):
9994
def _background_lint(self, cmd, code):
10095
folder = os.path.dirname(self.filename)
10196
things = [f for f in os.listdir(folder) if f.endswith(".go")]
97+
maxsee = settings.get("delay") * 1000
10298
nfiles = len(things)
10399

104-
if nfiles > MAX_FILES:
100+
if nfiles > maxsee:
101+
# Due to performance issues in golangci-lint, the linter will not
102+
# attempt to lint more than one-hundred (100) files considering a
103+
# delay of 100ms and lint_mode equal to “background”. If the user
104+
# increases the delay, the tool will have more time to scan more
105+
# files and analyze them.
105106
logger.warning("too many Go (golang) files ({})".format(nfiles))
106107
self.notify_failure()
107108
return ""

0 commit comments

Comments
 (0)