Skip to content

Commit d97886a

Browse files
author
Deyan Totev
committed
chore@small
1 parent 72a3590 commit d97886a

File tree

2 files changed

+276
-271
lines changed

2 files changed

+276
-271
lines changed

README.md

+3-271
Original file line numberDiff line numberDiff line change
@@ -1,273 +1,5 @@
1-
# Code Metrics - Visual Studio Code Extension
1+
# Code Complexity - Fork of Code Metrics
22

3-
Computes complexity in TypeScript / JavaScript / Lua files.
3+
Fork of https://github.com/kisstkondoros/codemetrics
44

5-
# Complexity calculation
6-
7-
The steps of the calculation:
8-
9-
- create an AST from the input source file
10-
- walk through each and every node of it
11-
- depending on the type of the node and the configuration associated with it create a new entry about the node.
12-
This entry contains everything necessary for further use
13-
(e.g. a textual representation for the node, complexity increment, child nodes etc.)
14-
- show the sum of complexity of child nodes for methods and the maximum of child nodes for classes
15-
16-
Please note that it is not a standard metric, but it is a close approximation
17-
of [Cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity).
18-
19-
Please also note that it is possible to balance the complexity calculation for the
20-
project / team / personal taste by adjusting the relevant configuration entries
21-
(content assist is provided for all of them for easier configuration).
22-
23-
For example if one prefers [guard clauses](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html),
24-
and is ok with all the branches in switch statements then the following could be applied:
25-
26-
```json
27-
"codemetrics.nodeconfiguration.ReturnStatement": 0,
28-
"codemetrics.nodeconfiguration.CaseClause": 0,
29-
"codemetrics.nodeconfiguration.DefaultClause": 0
30-
```
31-
32-
If You want to know the causes You can click on the code lens to list all the entries for a given method or class. (This also allows You to quickly navigate to the corresponding code)
33-
34-
![Metric details example, showing how one might check the overall complexity for a method by clicking on the codelens](https://raw.githubusercontent.com/kisstkondoros/codemetrics/master/images/metric_details.png)
35-
36-
## It looks like this
37-
38-
![First sample, demonstrating a constructor with overall complexity of 21](https://raw.githubusercontent.com/kisstkondoros/codemetrics/master/images/Sample1.png)
39-
40-
![Second sample, demonstrating a constructor with overall complexity of 1](https://raw.githubusercontent.com/kisstkondoros/codemetrics/master/images/Sample2.png)
41-
42-
![Third sample, demonstrating a method with overall complexity of 5](https://raw.githubusercontent.com/kisstkondoros/codemetrics/master/images/Sample3.png)
43-
44-
## Install
45-
46-
[How to install Visual Studio Code extensions](https://code.visualstudio.com/docs/editor/extension-gallery)
47-
48-
[Direct link to Visual Studio Code Marketplace](https://marketplace.visualstudio.com/items?itemName=kisstkondoros.vscode-codemetrics)
49-
50-
## Customization
51-
52-
In the workspace settings one can override the defaults.
53-
For a complete list please check the configuration section in the package.json.
54-
For the most commonly used ones, one should do a search for `codemetrics.basics`
55-
in the settings ui.
56-
57-
```javascript
58-
{
59-
// highest complexity level will be set when it exceeds 15
60-
"codemetrics.basics.ComplexityLevelExtreme" : 15,
61-
62-
// Hides code lenses with complexity lesser than the given value
63-
"codemetrics.basics.CodeLensHiddenUnder" : 5,
64-
65-
// Description for the highest complexity level
66-
"codemetrics.basics.ComplexityLevelExtremeDescription" : "OMG split this up!",
67-
68-
// someone uses 'any', it must be punished
69-
"codemetrics.nodeconfiguration.AnyKeyword": 100
70-
}
71-
```
72-
73-
## Commands
74-
75-
- Toggle code lenses for arrow functions
76-
- Toggle code metrics
77-
78-
They can be bound in the keybindings.json (File -> Preferences -> Keyboard Shortcuts)
79-
80-
```javascript
81-
{ "key": "f4", "command": "codemetrics.toggleCodeMetricsForArrowFunctions",
82-
"when": "editorTextFocus" },
83-
{ "key": "f5", "command": "codemetrics.toggleCodeMetricsDisplayed",
84-
"when": "editorTextFocus" }
85-
```
86-
87-
### Change Log
88-
89-
- 1.26.1
90-
- Update tsmetrics-core to 1.4.1 (fixes default for `IfWithElseStatement` )
91-
- 1.26.0
92-
- Update tsmetrics-core to 1.4.0 (comes with a new config `IgnoredFunctionNames`)
93-
- 1.25.2
94-
- Update tsmetrics-core to 1.3.1
95-
- 1.25.1
96-
- Update tsmetrics-core to 1.3.0
97-
- 1.25.0
98-
- Update dependencies
99-
- Make it work for vue setup scripts
100-
- 1.24.0
101-
- Jump to selection from the quick pick menu
102-
- 1.23.1
103-
- Update dependencies
104-
- 1.23.0
105-
- Use QuickPickItems instead of plain strings
106-
- Update tsmetrics-core to 1.2.1
107-
- 1.22.1
108-
- Update change log
109-
- 1.22.0
110-
- Update the activationEvents property (contribution from [@igorskyflyer](https://github.com/igorskyflyer) )
111-
- Add "onLanguage:vue" to the list of activation events
112-
- 1.21.0
113-
- Show all items in the quick pick menu
114-
- 1.20.0
115-
- Migrate to webpack
116-
- Adjust section about configuration options
117-
- Update tsmetrics-core
118-
- 1.19.1
119-
- Update dependencies
120-
- 1.19.0
121-
- Add support for ts based vue components
122-
- 1.18.1
123-
- Update dependencies
124-
- Fix rounding issues
125-
- 1.18.0
126-
- Add DecorationTemplate configuration (contribution from [@luchsamapparat](https://github.com/luchsamapparat) )
127-
- 1.17.4
128-
- Update dependencies
129-
- 1.17.3
130-
- Update dependencies
131-
- 1.17.2
132-
- Fix invalid default color definition
133-
- 1.17.1
134-
- Add file and untitled scheme explicitly
135-
- 1.17.0
136-
- Adjust codebase to new API standards of VSCode
137-
- Adjust filter boundaries which are used for color decorators
138-
- 1.16.0
139-
- Update dev dependency for vscode to avoid vulnerability warning
140-
- Add description about complexity calculation and configuration
141-
- 1.15.0
142-
- Update tsmetrics-core to v1.0.0
143-
- 1.14.0
144-
- Make decoration colors configurable
145-
- The following properties were introduced:
146-
- codemetrics.basics.ComplexityColorLow
147-
- codemetrics.basics.ComplexityColorNormal
148-
- codemetrics.basics.ComplexityColorHigh
149-
- codemetrics.basics.ComplexityColorExtreme
150-
- 1.13.0
151-
- Update vscode version to 1.1.10
152-
- Avoid indentation distortion by moving decorations to the end of the line
153-
- Debounce EditorDecoration update requests properly
154-
- 1.12.0
155-
- Add support for Visual Studio Live Share
156-
- 1.11.2
157-
- Improve decorator lifecycle management
158-
- 1.11.1
159-
- Only create new decorations if the settings has changed
160-
- 1.11.0
161-
- Add new mode OverviewRuler
162-
- Update tsmetrics-core and typescript dependencies
163-
- 1.10.0
164-
- Add support for embedded scripts in vue and html files
165-
- 1.9.6
166-
- Disable diagnostic report for code metrics
167-
- 1.9.5
168-
- Add .vscode-test to .vscodeignore
169-
- 1.9.4
170-
- Replace new line characters in quick pick menu with spaces
171-
- 1.9.3
172-
- Update readme
173-
- 1.9.2
174-
- Fix behavior of command 'codemetrics.toggleCodeMetricsForArrowFunctions'
175-
- 1.9.1
176-
- Set default of ObjectLiteralExpression to 0
177-
- 1.9.0
178-
- Implement file exclusion by glob pattern
179-
- 1.8.0
180-
- Upgrade to [email protected]
181-
- Use new collector types from tsmetrics-core (show complexity maximum on class level)
182-
- 1.7.2
183-
- Make it possible to enable / disable diagnostics
184-
- 1.7.1
185-
- Always use activeTextEditor in change callbacks
186-
- 1.7.0
187-
- Add experimental diagnostics support
188-
- Add experimental support for Lua
189-
- 1.6.1
190-
- Fix spelling error of 'threshold' in configuration
191-
- 1.6.0
192-
- Execute code metrics computation in language server
193-
- 1.5.0
194-
- Upgrade vsdcode and typescript dependency
195-
- Remove unused typings
196-
- Extract code metrics related util class
197-
- Move CodeMetricsCodeLensProvider to codelensprovider folder
198-
- Add text decoration based on code metrics
199-
- Appearance can be configured with the following properties:
200-
- "codemetrics.basics.DecorationModeEnabled"
201-
- "codemetrics.basics.CodeLensEnabled"
202-
- 1.4.1
203-
- Update changelog
204-
- 1.4.0
205-
- Expose code lens location related configuration properties
206-
- "codemetrics.basics.MetricsForClassDeclarationsToggled"
207-
- "codemetrics.basics.MetricsForConstructorsToggled"
208-
- "codemetrics.basics.MetricsForEnumDeclarationsToggled"
209-
- "codemetrics.basics.MetricsForFunctionDeclarationsToggled"
210-
- "codemetrics.basics.MetricsForFunctionExpressionsToggled"
211-
- "codemetrics.basics.MetricsForMethodDeclarationsToggled"
212-
- "codemetrics.basics.MetricsForArrowFunctionsToggled"
213-
- 1.3.0
214-
- Add new properties to selectively disable codemetrics for different languages
215-
- "codemetrics.basics.EnabledForTSX"
216-
- "codemetrics.basics.EnabledForJSX"
217-
- "codemetrics.basics.EnabledForTS"
218-
- "codemetrics.basics.EnabledForJS"
219-
- Introduce file size limit
220-
- "codemetrics.basics.FileSizeLimitMB" default is 0.5 MB
221-
- 1.2.2
222-
- Fix behaviour of CodeLensHiddenUnder
223-
- 1.2.1
224-
- Change type of IfWithElseStatement property to number
225-
- 1.2.0
226-
- Add JSX and TSX support, special thanks to [Aron Adler](https://github.com/Arrow7000)
227-
- 1.1.6
228-
- Fix possible NPE in 'triggerCodeLensComputation'
229-
- Remove language restriction from 'activationEvents'
230-
- 1.1.5
231-
- Udpate logo
232-
- 1.1.4
233-
- Change textual representation in quick pick
234-
- 1.1.3
235-
- Fix typo in codemetrics.basics.ComplexityLevelNormalDescription
236-
- 1.1.2
237-
- Fix dependency issue with 'fs'
238-
- 1.1.1
239-
- Fix issue with non up to date source file processing
240-
- 1.1.0
241-
- Parse logic refactored to be a separate npm module [tsmetrics-core](https://www.npmjs.com/package/tsmetrics-core) allowing to create a gulp plugin as well [gulp-tsmetrics](https://www.npmjs.com/package/gulp-tsmetrics)
242-
- QuickPick now works with a simplified and more meaningful list, which shows only one level of the hierarchy at once
243-
- 1.0.1
244-
- Default keyboard bindings removed
245-
- CodeLens cache invalidation side effect eliminated (dirty file)
246-
- Path concatenation replaced with path.join
247-
- 1.0.0
248-
- Configuration properties has been renamed and listed in extension manifest
249-
- New property CodeLensHiddenUnder introduced to be able to hide uninteresting code lenses
250-
- 0.5.0
251-
- Commands to alter code metrics behaviour added (toggle code metrics and toggle code lenses for arrow functions)
252-
- 0.4.1
253-
- Showing complexity for arrow functions as well
254-
- 0.4.0
255-
- Added JavaScript support
256-
- Removed module declaration from the complexity calculation
257-
- Function related complexity calculation revised
258-
- 0.3.1
259-
- Fixed NPE in navigation command
260-
- 0.3.0
261-
- Use script target defined in tsconfig
262-
- 0.2.0
263-
- Code Metrics info command changed to display a QuickPick menu
264-
- 0.1.0
265-
- Added command to be able to show code lens details
266-
- 0.0.2
267-
- TypeScript added as real dependency
268-
- 0.0.1
269-
- Initial project setup
270-
271-
### License
272-
273-
Licensed under MIT
5+
Difference is that instead of 4 levels of color decoration, there are 24 levels.

0 commit comments

Comments
 (0)