Skip to content

Commit

Permalink
Update several dependencies, improve safety, add test script (#119)
Browse files Browse the repository at this point in the history
* Update several dependencies

* Update badges

* Various safety and lint improvements

These are required to satisfy some new dependencies which exposed some safety and linting issues that were previously being overlooked

* Update test expectations, add script to automate that
  • Loading branch information
sgb-io authored Jan 10, 2023
1 parent 836db04 commit a0d2ece
Show file tree
Hide file tree
Showing 25 changed files with 4,997 additions and 3,365 deletions.
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ Note: the badges for codehawk-cli are tracked in git because
- There is currently no 3rd party API that can fetch codehawk results remotely
- There are no plans to expose codehawk results outside of a project

# Updating tests when changes result in materially different outputs

There is now a script to update all the static `expected.json` files: `yarn run test:updateexpectations`.

Note that this script runs "blind", i.e. assumes that the output is correct, and writes it to file, discarding whatever was there before. It's up to you to ensure that the changes are correct / valid.

## Releasing new versions

Note: currently, only the project owner (sgb-io) has access to publish new versions to npm.
Expand Down
8 changes: 4 additions & 4 deletions generated/avg-maintainability.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions generated/worst-maintainability.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test": "jest --testTimeout 15000",
"verify": "yarn build && yarn test && yarn lint && yarn prettier && yarn reflect && yarn isclean"
"verify": "yarn build && yarn test && yarn lint && yarn prettier && yarn reflect && yarn isclean",
"test:updateexpectations": "ts-node --files src/updateExpectedOutputs.ts"
},
"author": "Sam Brown (https://github.com/sgb-io)",
"repository": {
Expand All @@ -30,8 +31,8 @@
},
"license": "MIT",
"dependencies": {
"@babel/core": "^7.18.6",
"@babel/plugin-transform-typescript": "^7.18.6",
"@babel/core": "^7.20.12",
"@babel/plugin-transform-typescript": "^7.20.7",
"badgen": "^3.2.2",
"flow-remove-types": "^2.111.3",
"is-dotdir": "^1.0.1",
Expand All @@ -57,10 +58,11 @@
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "4",
"eslint-plugin-standard": "4",
"jest": "^28.1.2",
"jest": "^28.1.3",
"np": "^7.6.2",
"prettier": "^2.7.1",
"ts-jest": "^28.0.5",
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"files": [
Expand Down
239 changes: 142 additions & 97 deletions samples/contains-some-bad-code/expected.json
Original file line number Diff line number Diff line change
@@ -1,97 +1,142 @@
{
"summary": {
"average": 58.93321508519464,
"median": 58.93321508519464,
"worst": 58.93321508519464
},
"resultsList": [
{
"fullPath": "/samples/contains-some-bad-code/good-code.ts",
"filename": "good-code.ts",
"shouldAnalyze": true,
"path": "/samples/contains-some-bad-code",
"type": "file",
"complexityReport": {
"aggregate": {
"cyclomatic": 11,
"cyclomaticDensity": 37.931,
"halstead": {
"bugs": 0.217,
"difficulty": 35.889,
"effort": 23378.702,
"length": 127,
"time": 1298.817,
"vocabulary": 35,
"volume": 651.419,
"operands": { "distinct": 18, "total": 76 },
"operators": { "distinct": 17, "total": 51 }
},
"paramCount": 9,
"sloc": { "logical": 29, "physical": 50 }
},
"dependencies": [],
"errors": [],
"lineEnd": 50,
"lineStart": 1,
"maintainability": 108.234,
"codehawkScore": 58.93321508519464,
"coverage": "0"
},
"timesDependedOn": 0
}
],
"fullResultsTree": [
{
"fullPath": "/samples/contains-some-bad-code/bad-code.ts",
"filename": "bad-code.ts",
"shouldAnalyze": true,
"path": "/samples/contains-some-bad-code",
"type": "file",
"complexityReport": null,
"timesDependedOn": 0
},
{
"fullPath": "/samples/contains-some-bad-code/expected.json",
"filename": "expected.json",
"shouldAnalyze": false,
"path": "/samples/contains-some-bad-code",
"type": "file",
"complexityReport": null,
"timesDependedOn": 0
},
{
"fullPath": "/samples/contains-some-bad-code/good-code.ts",
"filename": "good-code.ts",
"shouldAnalyze": true,
"path": "/samples/contains-some-bad-code",
"type": "file",
"complexityReport": {
"aggregate": {
"cyclomatic": 11,
"cyclomaticDensity": 37.931,
"halstead": {
"bugs": 0.217,
"difficulty": 35.889,
"effort": 23378.702,
"length": 127,
"time": 1298.817,
"vocabulary": 35,
"volume": 651.419,
"operands": { "distinct": 18, "total": 76 },
"operators": { "distinct": 17, "total": 51 }
},
"paramCount": 9,
"sloc": { "logical": 29, "physical": 50 }
},
"dependencies": [],
"errors": [],
"lineEnd": 50,
"lineStart": 1,
"maintainability": 108.234,
"codehawkScore": 58.93321508519464,
"coverage": "0"
},
"timesDependedOn": 0
}
]
}
{
"options": {
"badgesDirectory": [
"/generated"
],
"extensions": [
".js",
".jsx",
".ts",
".tsx"
],
"excludeDirectories": [
"/dist",
"/bin",
"/build"
],
"excludeExact": [],
"excludeFilenames": [
".d.ts",
".min.js",
".bundle.js"
],
"skipDirectories": [
"/node_modules",
"/flow-typed",
"/coverage"
],
"minimumThreshold": 10,
"cliOutputLimit": 25
},
"summary": {
"average": 60.8132766099468,
"median": 60.8132766099468,
"worst": 60.8132766099468
},
"resultsList": [
{
"fullPath": "/samples/contains-some-bad-code/good-code.ts",
"filename": "good-code.ts",
"shouldAnalyze": true,
"path": "/samples/contains-some-bad-code",
"type": "file",
"complexityReport": {
"aggregate": {
"cyclomatic": 11,
"cyclomaticDensity": 37.931,
"halstead": {
"bugs": 0.217,
"difficulty": 35.889,
"effort": 23378.702,
"length": 127,
"time": 1298.817,
"vocabulary": 35,
"volume": 651.419,
"operands": {
"distinct": 18,
"total": 76
},
"operators": {
"distinct": 17,
"total": 51
}
},
"paramCount": 9,
"sloc": {
"logical": 29,
"physical": 41
}
},
"dependencies": [],
"errors": [],
"lineEnd": 41,
"lineStart": 1,
"maintainability": 108.234,
"codehawkScore": 60.8132766099468,
"coverage": "0"
},
"timesDependedOn": 0
}
],
"fullResultsTree": [
{
"fullPath": "/samples/contains-some-bad-code/bad-code.ts",
"filename": "bad-code.ts",
"shouldAnalyze": true,
"path": "/samples/contains-some-bad-code",
"type": "file",
"timesDependedOn": 0
},
{
"fullPath": "/samples/contains-some-bad-code/expected.json",
"filename": "expected.json",
"shouldAnalyze": false,
"path": "/samples/contains-some-bad-code",
"type": "file",
"timesDependedOn": 0
},
{
"fullPath": "/samples/contains-some-bad-code/good-code.ts",
"filename": "good-code.ts",
"shouldAnalyze": true,
"path": "/samples/contains-some-bad-code",
"type": "file",
"complexityReport": {
"aggregate": {
"cyclomatic": 11,
"cyclomaticDensity": 37.931,
"halstead": {
"bugs": 0.217,
"difficulty": 35.889,
"effort": 23378.702,
"length": 127,
"time": 1298.817,
"vocabulary": 35,
"volume": 651.419,
"operands": {
"distinct": 18,
"total": 76
},
"operators": {
"distinct": 17,
"total": 51
}
},
"paramCount": 9,
"sloc": {
"logical": 29,
"physical": 41
}
},
"dependencies": [],
"errors": [],
"lineEnd": 41,
"lineStart": 1,
"maintainability": 108.234,
"codehawkScore": 60.8132766099468,
"coverage": "0"
},
"timesDependedOn": 0
}
]
}
Loading

0 comments on commit a0d2ece

Please sign in to comment.