Skip to content

Commit 4bfe649

Browse files
committed
Normalize code format using editorconfig and prettier
1 parent 29c75cd commit 4bfe649

14 files changed

+796
-675
lines changed

Diff for: .editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = crlf
5+
insert_final_newline = true
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 4
9+
10+
[package.json]
11+
indent_size = 2
12+
end_of_line = lf

Diff for: .prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"printWidth": 120
3+
}

Diff for: package.json

+9-16
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,9 @@
1515
"type": "git",
1616
"url": "https://github.com/kisstkondoros/codemetrics.git"
1717
},
18-
"keywords": [
19-
"vscode",
20-
"code",
21-
"metrics",
22-
"typescript",
23-
"javascript"
24-
],
25-
"categories": [
26-
"Other"
27-
],
28-
"activationEvents": [
29-
"*"
30-
],
18+
"keywords": ["vscode", "code", "metrics", "typescript", "javascript"],
19+
"categories": ["Other"],
20+
"activationEvents": ["*"],
3121
"contributes": {
3222
"commands": [
3323
{
@@ -100,12 +90,14 @@
10090
},
10191
"codemetrics.basics.MetricsForArrowFunctionsToggled": {
10292
"default": true,
103-
"description": "A flag which indicates whether code metrics are enabled for arrow functions (can also be toggled via a command)",
93+
"description":
94+
"A flag which indicates whether code metrics are enabled for arrow functions (can also be toggled via a command)",
10495
"type": "boolean"
10596
},
10697
"codemetrics.basics.FileSizeLimitMB": {
10798
"default": 0.5,
108-
"description": "File size limit in megabytes, above this codemetrics are not going to be computed, use a negative number to allow any size",
99+
"description":
100+
"File size limit in megabytes, above this codemetrics are not going to be computed, use a negative number to allow any size",
109101
"type": "number"
110102
},
111103
"codemetrics.basics.EnabledForVue": {
@@ -190,7 +182,8 @@
190182
},
191183
"codemetrics.basics.ComplexityTemplate": {
192184
"default": "Complexity is {0} {1}",
193-
"description": "Code lens message template {0} stands for the actual value {1} is for the complexity level description",
185+
"description":
186+
"Code lens message template {0} stands for the actual value {1} is for the complexity level description",
194187
"type": "string"
195188
},
196189
"codemetrics.luaconfiguration.LabelStatement": {

Diff for: src/codelensprovider/CodeMetricsCodeLensProvider.ts

+35-33
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
1-
import { CodeLensProvider, TextDocument, CodeLens, CancellationToken, workspace } from 'vscode';
2-
import { CodeMetricsCodeLens } from '../models/CodeMetricsCodeLens';
3-
import { IMetricsModel } from 'tsmetrics-core';
4-
import { MetricsUtil } from "../metrics/MetricsUtil";
5-
6-
export class CodeMetricsCodeLensProvider implements CodeLensProvider {
7-
private metricsUtil: MetricsUtil;
8-
9-
constructor(metricsUtil: MetricsUtil) {
10-
this.metricsUtil = metricsUtil;
11-
}
12-
13-
provideCodeLenses(document: TextDocument, token: CancellationToken): Thenable<CodeLens[]> {
14-
if (!this.metricsUtil.appConfig.codeMetricsDisplayed) return;
15-
if (!this.metricsUtil.appConfig.codeMetricsSettings.CodeLensEnabled) return;
16-
return this.metricsUtil.getMetrics(document).then(metrics => {
17-
const result: CodeLens[] = metrics.map(model => new CodeMetricsCodeLens(model, this.metricsUtil.toRange(model, document)))
18-
return result;
19-
});
20-
}
21-
22-
resolveCodeLens(codeLens: CodeLens, token: CancellationToken): CodeLens {
23-
if (codeLens instanceof CodeMetricsCodeLens) {
24-
codeLens.command = {
25-
title: this.metricsUtil.format(codeLens),
26-
command: "codemetrics.showCodeMetricsCodeLensInfo",
27-
arguments: [codeLens]
28-
};
29-
return codeLens;
30-
}
31-
return null;
32-
}
33-
}
1+
import { CodeLensProvider, TextDocument, CodeLens, CancellationToken, workspace } from "vscode";
2+
import { CodeMetricsCodeLens } from "../models/CodeMetricsCodeLens";
3+
import { IMetricsModel } from "tsmetrics-core";
4+
import { MetricsUtil } from "../metrics/MetricsUtil";
5+
6+
export class CodeMetricsCodeLensProvider implements CodeLensProvider {
7+
private metricsUtil: MetricsUtil;
8+
9+
constructor(metricsUtil: MetricsUtil) {
10+
this.metricsUtil = metricsUtil;
11+
}
12+
13+
provideCodeLenses(document: TextDocument, token: CancellationToken): Thenable<CodeLens[]> {
14+
if (!this.metricsUtil.appConfig.codeMetricsDisplayed) return;
15+
if (!this.metricsUtil.appConfig.codeMetricsSettings.CodeLensEnabled) return;
16+
return this.metricsUtil.getMetrics(document).then(metrics => {
17+
const result: CodeLens[] = metrics.map(
18+
model => new CodeMetricsCodeLens(model, this.metricsUtil.toRange(model, document))
19+
);
20+
return result;
21+
});
22+
}
23+
24+
resolveCodeLens(codeLens: CodeLens, token: CancellationToken): CodeLens {
25+
if (codeLens instanceof CodeMetricsCodeLens) {
26+
codeLens.command = {
27+
title: this.metricsUtil.format(codeLens),
28+
command: "codemetrics.showCodeMetricsCodeLensInfo",
29+
arguments: [codeLens]
30+
};
31+
return codeLens;
32+
}
33+
return null;
34+
}
35+
}

0 commit comments

Comments
 (0)