Skip to content

Commit

Permalink
refactor + add debounce (close #41)
Browse files Browse the repository at this point in the history
  • Loading branch information
tenninebt committed Oct 26, 2023
1 parent efa064d commit 2645ca5
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 205 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"env": {
"browser": false,
"es2021": true
"es2022": true
},
"extends": ["standard-with-typescript", "prettier"],
"overrides": [],
Expand All @@ -11,7 +11,8 @@
"project": "tsconfig.json"
},
"rules": {
"@typescript-eslint/strict-boolean-expressions": "off"
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/no-confusing-void-expression": "off"
},
"ignorePatterns": ["*.js", "**/node_modules/"]
}
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ This extension adds a tree view to the test view container. It shows the coverag

This extension contributes the following settings:

* `koverage.coverageFileNames`: coverage file names to look for, default: ["lcov.info", "cov.xml", "coverage.xml","jacoco.xml"]
* `koverage.coverageFilePaths`: coverage paths where coverage files are located, default: ["coverage"]
* `koverage.lowCoverageThreshold`: Percentage under which, the coverage is considered too low (Renders as Error icon)
* `koverage.sufficientCoverageThreshold`: Percentage above which, the coverage is considered sufficient (Renders as Success icon)
- `koverage.coverageCommand`: Command to run to generate coverage. (Default: "")
- `koverage.autoRefresh`: Whether to watch the coverage files and configurations. (Default: true)
- `koverage.autoRefreshDebounce`: Auto refresh debounce interval in milliseconds. (Default: 3000)
- `koverage.coverageFileNames`: Coverage file names to look for. (Default: ["lcov.info", "cov.xml", "coverage.xml", "jacoco.xml"])
- `koverage.coverageFilePaths`: Coverage file paths to search in. (Default: ["**"])
- `koverage.ignoredPathGlobs`: Ignored path globs. (Default: "**/{node_modules,venv,.venv,vendor}/**")
- `koverage.lowCoverageThreshold`: Coverage threshold considered too low. (Default: 50)
- `koverage.sufficientCoverageThreshold`: Coverage threshold considered sufficient. (Default: 70)
=> lowCoverageThreshold < level < sufficientCoverageThreshold is rendered as Warn icon

## Licencing
Expand Down
24 changes: 20 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"keywords": [
"coverage",
"lcov",
"jacoco"
"jacoco",
"clover"
],
"repository": "https://github.com/tenninebt/vscode-koverage",
"description": "View the code coverage per folder/file in the test view",
Expand All @@ -31,23 +32,36 @@
"description": "command to run to generate coverage",
"scope": "resource"
},
"koverage.autoRefresh": {
"type": "boolean",
"default": true,
"description": "Whether to watch the coverage files and configurations",
"scope": "resource"
},
"koverage.autoRefreshDebounce": {
"type": "number",
"default": 3000,
"description": "Auto refresh debounce interval in milliseconds",
"scope": "resource"
},
"koverage.coverageFileNames": {
"type": "array",
"default": [
"lcov.info",
"cov.xml",
"clover.xml",
"coverage.xml",
"jacoco.xml"
],
"description": "coverage file names for the extension to automatically look for",
"description": "coverage file names to look for",
"scope": "resource"
},
"koverage.coverageFilePaths": {
"type": "array",
"default": [
"**"
],
"description": "coverage file paths for the extensions to automatically search in",
"description": "coverage file paths to search in",
"scope": "resource"
},
"koverage.ignoredPathGlobs": {
Expand Down Expand Up @@ -121,10 +135,11 @@
}
},
"scripts": {
"clean": "rm -rf dist",
"compile": "yarn clean && tsc",
"build:prod": "webpack --mode production",
"build:dev": "webpack --mode development",
"build:watch": "webpack --mode development --watch",
"compile": "tsc",
"lint": "eslint ./src"
},
"devDependencies": {
Expand All @@ -140,6 +155,7 @@
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-promise": "^6.1.1",
"ovsx": "^0.8.0",
"ts-loader": "^9.5.0",
"typescript": "^5.0.3",
"vscode-test": "^1.3.0",
"webpack": "^5.74.0",
Expand Down
7 changes: 3 additions & 4 deletions src/ConfigStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export class ConfigStore {
private readonly configurationKey: string = "koverage"

private readonly _configChangedNotifier: rx.Subject<void>
public readonly configChangedNotifier: rx.Observable<void>

private readonly _perFolderConfig: Map<vscode.Uri, rx.BehaviorSubject<Config>>
public get(workspaceFolder: vscode.WorkspaceFolder): Config {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand All @@ -14,6 +16,7 @@ export class ConfigStore {

constructor(private readonly logger: vscodeLogging.IVSCodeExtLogger) {
this._configChangedNotifier = new rx.Subject<void>()
this.configChangedNotifier = this._configChangedNotifier.asObservable()
this._perFolderConfig = new Map<vscode.Uri, rx.BehaviorSubject<Config>>()

void this.readConfig()
Expand Down Expand Up @@ -93,10 +96,6 @@ export class ConfigStore {
sufficientCoverageThreshold
})
}

public subscribe(next?: () => void, error?: (error: any) => void, complete?: () => void): rx.Subscription {
return this._configChangedNotifier.subscribe(next, error, complete)
}
}

export class Config {
Expand Down
10 changes: 10 additions & 0 deletions src/CoverageLevel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

export enum CoverageLevel {
Low = "low",
Medium = "medium",
High = "high"
}

export class CoverageLevelThresholds {
constructor(public readonly sufficientCoverageThreshold: number, public readonly lowCoverageThreshold: number) { }
}
Loading

0 comments on commit 2645ca5

Please sign in to comment.