Skip to content

Commit

Permalink
fix: remove Force Exclude Paths #39
Browse files Browse the repository at this point in the history
  • Loading branch information
vknabel committed Dec 12, 2022
1 parent e6bb573 commit 61221fc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 60 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- removed: `swiftlint.forceExcludePaths` as it didn't work. Use `excluded` in your `.swiftlint` config instead. #39

## 1.7.3

- fix: Unrecognized arguments: --format #47 #55
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ let package = Package(

## Configuration

| Config | Type | Default | Description |
| --------------------------------------- | ---------- | -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `swiftlint.enable` | `Bool` | `true` | Whether SwiftLint should actually do something. |
| `swiftlint.onlyEnableOnSwiftPMProjects` | `Bool` | `false` | Requires and uses a SwiftLint as SwiftPM dependency. |
| `swiftlint.onlyEnableWithConfig` | `Bool` | `false` | Only lint if config present. |
| `swiftlint.path` | `String` | `/usr/local/bin/swiftlint` | The location of the globally installed SwiftLint. |
| `swiftlint.additionalParameters` | `[String]` | `["--format"]` | Additional parameters to pass to SwiftLint. |
| `swiftlint.configSearchPaths` | `[String]` | `[]` | Possible paths for SwiftLint config. _This disables [nested configurations](https://github.com/realm/SwiftLint#nested-configurations)!_ |
| `swiftlint.forceExcludePaths` | `[String]` | `["tmp","build",".build","Pods","Carthage"]` | Paths to be excluded from being passed to SwiftLint. |
| `swiftlint.autoLintWorkspace` | `Bool` | `true` | Automatically lint the whole project right after start. |
| Config | Type | Default | Description |
| --------------------------------------- | ---------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `swiftlint.enable` | `Bool` | `true` | Whether SwiftLint should actually do something. |
| `swiftlint.onlyEnableOnSwiftPMProjects` | `Bool` | `false` | Requires and uses a SwiftLint as SwiftPM dependency. |
| `swiftlint.onlyEnableWithConfig` | `Bool` | `false` | Only lint if config present. |
| `swiftlint.path` | `String` | `/usr/local/bin/swiftlint` | The location of the globally installed SwiftLint. |
| `swiftlint.additionalParameters` | `[String]` | `["--format"]` | Additional parameters to pass to SwiftLint. |
| `swiftlint.configSearchPaths` | `[String]` | `[]` | Possible paths for SwiftLint config. _This disables [nested configurations](https://github.com/realm/SwiftLint#nested-configurations)!_ |
| `swiftlint.autoLintWorkspace` | `Bool` | `true` | Automatically lint the whole project right after start. |

## Commands

Expand Down
14 changes: 0 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,6 @@
"type": "string"
}
},
"swiftlint.forceExcludePaths": {
"type": "array",
"description": "Paths to be excluded from being passed to SwiftLint.",
"default": [
"tmp",
"build",
".build",
"Pods",
"Carthage"
],
"items": {
"type": "string"
}
},
"swiftlint.autoLintWorkspace": {
"type": "boolean",
"description": "Automatically lint the whole project right after start.",
Expand Down
11 changes: 0 additions & 11 deletions src/Current.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export interface Current {
resetSwiftLintPath(): void;
openSettings(): void;
lintConfigSearchPaths(): string[];
forceExcludePaths(): string[];
autoLintWorkspace(): boolean;
};
}
Expand Down Expand Up @@ -157,16 +156,6 @@ export function prodEnvironment(): Current {
.getConfiguration()
.get("swiftlint.configSearchPaths", [])
.map(absolutePath),
forceExcludePaths: () =>
vscode.workspace
.getConfiguration()
.get<string[]>("swiftlint.forceExcludePaths", [
"tmp",
"build",
".build",
"Pods",
"Carthage",
]),
},
};
}
Expand Down
21 changes: 2 additions & 19 deletions src/SwiftLintProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,7 @@ export class SwiftLint {
parameters: [],
workspaceFolder,
});
this.diagnosticCollection.set(
document.uri,
this.isForceExcluded(
path.relative(workspaceFolder?.uri.fsPath ?? "/", document.uri.fsPath)
)
? []
: diagnostics
);
this.diagnosticCollection.set(document.uri, diagnostics);
this.latestDocumentVersion.set(document.uri, document.version);
} catch (error) {
handleFormatError(error, document.uri);
Expand Down Expand Up @@ -211,7 +204,7 @@ export class SwiftLint {
for (const file of diagnosticsByFile.keys()) {
this.diagnosticCollection.set(
folder.uri.with({ path: file }),
this.isForceExcluded(file) ? [] : diagnosticsByFile.get(file)
diagnosticsByFile.get(file)
);
}
} catch (error) {
Expand All @@ -223,14 +216,4 @@ export class SwiftLint {

await Promise.all(lintWorkspaces);
}

private isForceExcluded(relativePath: string): boolean {
for (const exclude of Current.config.forceExcludePaths()) {
const excluded = match([relativePath], exclude, { matchBase: true });
if (excluded.length > 0) {
return true;
}
}
return false;
}
}
7 changes: 1 addition & 6 deletions src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,11 @@ async function detectDefaultPathArguments(
workspaceFolder: WorkspaceFolder
): Promise<string[]> {
const fileUris = await workspace.findFiles(
new RelativePattern(workspaceFolder, "**/*.swift"),
new RelativePattern(workspaceFolder, forceExcludePathsPattern())
new RelativePattern(workspaceFolder, "**/*.swift")
);
return fileUris.map((uri) => uri.path);
}

function forceExcludePathsPattern(): string {
return "**/{" + Current.config.forceExcludePaths().join(",") + "}/***";
}

function reportToPreciseDiagnosticForDocument(
document: TextDocument
): (report: Report) => Diagnostic {
Expand Down

0 comments on commit 61221fc

Please sign in to comment.