ts2famix 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +24 -24
- package/LICENSE +23 -23
- package/README.md +109 -109
- package/jest.config-old.ts +199 -199
- package/package.json +47 -47
- package/src/analyze.ts +94 -94
- package/src/analyze_functions/processAccesses.ts +57 -57
- package/src/analyze_functions/processFiles.ts +669 -661
- package/src/analyze_functions/processImportClauses.ts +77 -77
- package/src/analyze_functions/processInheritances.ts +84 -84
- package/src/analyze_functions/processInvocations.ts +51 -51
- package/src/famix2puml.ts +119 -119
- package/src/famix_functions/famix_functions.ts +559 -555
- package/src/famix_functions/famix_functions_associations.ts +215 -215
- package/src/famix_functions/famix_functions_index.ts +44 -44
- package/src/famix_functions/famix_functions_types.ts +105 -100
- package/src/generate_uml.sh +16 -16
- package/src/lib/famix/License.md +22 -22
- package/src/lib/famix/package-lock.json +301 -301
- package/src/lib/famix/package.json +27 -27
- package/src/lib/famix/readme.md +4 -4
- package/src/lib/famix/src/famix_JSON_exporter.ts +56 -56
- package/src/lib/famix/src/famix_base_element.ts +18 -18
- package/src/lib/famix/src/famix_repository.ts +199 -199
- package/src/lib/famix/src/index.ts +8 -8
- package/src/lib/famix/src/model/famix/access.ts +53 -53
- package/src/lib/famix/src/model/famix/accessor.ts +15 -15
- package/src/lib/famix/src/model/famix/alias.ts +41 -41
- package/src/lib/famix/src/model/famix/association.ts +44 -44
- package/src/lib/famix/src/model/famix/behavioral_entity.ts +107 -107
- package/src/lib/famix/src/model/famix/c_source_language.ts +15 -15
- package/src/lib/famix/src/model/famix/class.ts +86 -86
- package/src/lib/famix/src/model/famix/comment.ts +50 -50
- package/src/lib/famix/src/model/famix/container_entity.ts +165 -165
- package/src/lib/famix/src/model/famix/custom_source_language.ts +27 -27
- package/src/lib/famix/src/model/famix/decorator.ts +39 -39
- package/src/lib/famix/src/model/famix/entity.ts +15 -15
- package/src/lib/famix/src/model/famix/enum.ts +31 -31
- package/src/lib/famix/src/model/famix/enum_value.ts +29 -29
- package/src/lib/famix/src/model/famix/function.ts +15 -15
- package/src/lib/famix/src/model/famix/implicit_variable.ts +15 -15
- package/src/lib/famix/src/model/famix/import_clause.ts +53 -53
- package/src/lib/famix/src/model/famix/index.ts +42 -42
- package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +49 -49
- package/src/lib/famix/src/model/famix/inheritance.ts +42 -42
- package/src/lib/famix/src/model/famix/interface.ts +75 -75
- package/src/lib/famix/src/model/famix/invocation.ts +68 -68
- package/src/lib/famix/src/model/famix/method.ts +96 -96
- package/src/lib/famix/src/model/famix/module.ts +31 -31
- package/src/lib/famix/src/model/famix/named_entity.ts +98 -98
- package/src/lib/famix/src/model/famix/namespace.ts +28 -28
- package/src/lib/famix/src/model/famix/parameter.ts +29 -29
- package/src/lib/famix/src/model/famix/parameterizable_class.ts +31 -31
- package/src/lib/famix/src/model/famix/parameterizable_interface.ts +31 -31
- package/src/lib/famix/src/model/famix/parameterized_type.ts +40 -40
- package/src/lib/famix/src/model/famix/primitive_type.ts +15 -15
- package/src/lib/famix/src/model/famix/property.ts +54 -54
- package/src/lib/famix/src/model/famix/reference.ts +42 -42
- package/src/lib/famix/src/model/famix/scoping_entity.ts +31 -31
- package/src/lib/famix/src/model/famix/script_entity.ts +38 -38
- package/src/lib/famix/src/model/famix/source_anchor.ts +31 -31
- package/src/lib/famix/src/model/famix/source_language.ts +31 -31
- package/src/lib/famix/src/model/famix/sourced_entity.ts +70 -70
- package/src/lib/famix/src/model/famix/structural_entity.ts +44 -44
- package/src/lib/famix/src/model/famix/text_anchor.ts +49 -49
- package/src/lib/famix/src/model/famix/type.ts +88 -88
- package/src/lib/famix/src/model/famix/type_parameter.ts +33 -33
- package/src/lib/famix/src/model/famix/variable.ts +28 -28
- package/src/lib/famix/tsconfig.json +26 -26
- package/src/lib/famix/tslint.json +14 -14
- package/src/lib/ts-complex/cyclomatic-service.ts +85 -85
- package/src/ts2famix-cli.ts +39 -39
- package/tsconfig.json +69 -69
- package/dist/analyze.js +0 -102
- package/dist/analyze_functions/processAccesses.js +0 -47
- package/dist/analyze_functions/processFiles.js +0 -540
- package/dist/analyze_functions/processImportClauses.js +0 -70
- package/dist/analyze_functions/processInheritances.js +0 -73
- package/dist/analyze_functions/processInvocations.js +0 -49
- package/dist/famix2puml.js +0 -125
- package/dist/famix_functions/famix_functions.js +0 -513
- package/dist/famix_functions/famix_functions_associations.js +0 -205
- package/dist/famix_functions/famix_functions_index.js +0 -62
- package/dist/famix_functions/famix_functions_types.js +0 -110
- package/dist/fqn.js +0 -126
- package/dist/fqp_implementation.js +0 -73
- package/dist/lib/famix/src/famix_JSON_exporter.js +0 -54
- package/dist/lib/famix/src/famix_base_element.js +0 -13
- package/dist/lib/famix/src/famix_repository.js +0 -187
- package/dist/lib/famix/src/index.js +0 -30
- package/dist/lib/famix/src/model/famix/access.js +0 -39
- package/dist/lib/famix/src/model/famix/accessor.js +0 -16
- package/dist/lib/famix/src/model/famix/alias.js +0 -32
- package/dist/lib/famix/src/model/famix/association.js +0 -36
- package/dist/lib/famix/src/model/famix/behavioral_entity.js +0 -81
- package/dist/lib/famix/src/model/famix/c_source_language.js +0 -16
- package/dist/lib/famix/src/model/famix/class.js +0 -70
- package/dist/lib/famix/src/model/famix/comment.js +0 -38
- package/dist/lib/famix/src/model/famix/container_entity.js +0 -125
- package/dist/lib/famix/src/model/famix/custom_source_language.js +0 -23
- package/dist/lib/famix/src/model/famix/decorator.js +0 -31
- package/dist/lib/famix/src/model/famix/entity.js +0 -16
- package/dist/lib/famix/src/model/famix/enum.js +0 -30
- package/dist/lib/famix/src/model/famix/enum_value.js +0 -24
- package/dist/lib/famix/src/model/famix/function.js +0 -16
- package/dist/lib/famix/src/model/famix/implicit_variable.js +0 -16
- package/dist/lib/famix/src/model/famix/import_clause.js +0 -39
- package/dist/lib/famix/src/model/famix/index.js +0 -87
- package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +0 -37
- package/dist/lib/famix/src/model/famix/inheritance.js +0 -32
- package/dist/lib/famix/src/model/famix/interface.js +0 -63
- package/dist/lib/famix/src/model/famix/invocation.js +0 -53
- package/dist/lib/famix/src/model/famix/method.js +0 -66
- package/dist/lib/famix/src/model/famix/module.js +0 -30
- package/dist/lib/famix/src/model/famix/named_entity.js +0 -77
- package/dist/lib/famix/src/model/famix/namespace.js +0 -24
- package/dist/lib/famix/src/model/famix/parameter.js +0 -24
- package/dist/lib/famix/src/model/famix/parameterizable_class.js +0 -30
- package/dist/lib/famix/src/model/famix/parameterizable_interface.js +0 -30
- package/dist/lib/famix/src/model/famix/parameterized_type.js +0 -36
- package/dist/lib/famix/src/model/famix/primitive_type.js +0 -16
- package/dist/lib/famix/src/model/famix/property.js +0 -44
- package/dist/lib/famix/src/model/famix/reference.js +0 -32
- package/dist/lib/famix/src/model/famix/scoping_entity.js +0 -30
- package/dist/lib/famix/src/model/famix/script_entity.js +0 -30
- package/dist/lib/famix/src/model/famix/source_anchor.js +0 -26
- package/dist/lib/famix/src/model/famix/source_language.js +0 -30
- package/dist/lib/famix/src/model/famix/sourced_entity.js +0 -55
- package/dist/lib/famix/src/model/famix/structural_entity.js +0 -38
- package/dist/lib/famix/src/model/famix/text_anchor.js +0 -37
- package/dist/lib/famix/src/model/famix/type.js +0 -71
- package/dist/lib/famix/src/model/famix/type_parameter.js +0 -24
- package/dist/lib/famix/src/model/famix/variable.js +0 -23
- package/dist/lib/ts-complex/cyclomatic-service.js +0 -83
- package/dist/ts2famix-cli.js +0 -63
- package/dist/ts2famix-tsconfig.js +0 -53
- package/metrics.ts +0 -23
- package/output.debug.txt +0 -1351
- package/src/fqp_implementation.ts +0 -66
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Portions of this file:
|
|
4
|
-
|
|
5
|
-
MIT License
|
|
6
|
-
|
|
7
|
-
Copyright (c) 2018 Anand Undavia
|
|
8
|
-
|
|
9
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.calculate = void 0;
|
|
17
|
-
const typescript_1 = require("typescript");
|
|
18
|
-
const tsutils_1 = require("tsutils");
|
|
19
|
-
const fs_1 = require("fs");
|
|
20
|
-
const { isIdentifier } = require('typescript');
|
|
21
|
-
const getNodeName = (node) => {
|
|
22
|
-
const { name, pos, end } = node;
|
|
23
|
-
const key = name !== undefined && isIdentifier(name) ? name.text : JSON.stringify({ pos, end });
|
|
24
|
-
return key;
|
|
25
|
-
};
|
|
26
|
-
const increasesComplexity = (node) => {
|
|
27
|
-
/* eslint-disable indent */
|
|
28
|
-
switch (node.kind) {
|
|
29
|
-
case typescript_1.SyntaxKind.CaseClause:
|
|
30
|
-
return node.statements.length > 0;
|
|
31
|
-
case typescript_1.SyntaxKind.CatchClause:
|
|
32
|
-
case typescript_1.SyntaxKind.ConditionalExpression:
|
|
33
|
-
case typescript_1.SyntaxKind.DoStatement:
|
|
34
|
-
case typescript_1.SyntaxKind.ForStatement:
|
|
35
|
-
case typescript_1.SyntaxKind.ForInStatement:
|
|
36
|
-
case typescript_1.SyntaxKind.ForOfStatement:
|
|
37
|
-
case typescript_1.SyntaxKind.IfStatement:
|
|
38
|
-
case typescript_1.SyntaxKind.WhileStatement:
|
|
39
|
-
return true;
|
|
40
|
-
case typescript_1.SyntaxKind.BinaryExpression:
|
|
41
|
-
switch (node.operatorToken.kind) {
|
|
42
|
-
case typescript_1.SyntaxKind.BarBarToken:
|
|
43
|
-
case typescript_1.SyntaxKind.AmpersandAmpersandToken:
|
|
44
|
-
return true;
|
|
45
|
-
default:
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
default:
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
/* eslint-enable indent */
|
|
52
|
-
};
|
|
53
|
-
const calculateFromSource = (ctx) => {
|
|
54
|
-
let complexity = 0;
|
|
55
|
-
const output = {};
|
|
56
|
-
(0, typescript_1.forEachChild)(ctx, function cb(node) {
|
|
57
|
-
var _a;
|
|
58
|
-
if ((0, tsutils_1.isFunctionWithBody)(node)) {
|
|
59
|
-
const old = complexity;
|
|
60
|
-
complexity = 1;
|
|
61
|
-
(0, typescript_1.forEachChild)(node, cb);
|
|
62
|
-
const name = (_a = getNodeName(node)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
63
|
-
output[name] = complexity;
|
|
64
|
-
complexity = old;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
if (increasesComplexity(node)) {
|
|
68
|
-
complexity += 1;
|
|
69
|
-
}
|
|
70
|
-
(0, typescript_1.forEachChild)(node, cb);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return output;
|
|
74
|
-
};
|
|
75
|
-
const calculate = (filePath) => {
|
|
76
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
77
|
-
throw new Error(`File "${filePath}" does not exists`);
|
|
78
|
-
}
|
|
79
|
-
const sourceText = (0, fs_1.readFileSync)(filePath).toString();
|
|
80
|
-
const source = (0, typescript_1.createSourceFile)(filePath, sourceText, isIdentifier.ES2015);
|
|
81
|
-
return calculateFromSource(source);
|
|
82
|
-
};
|
|
83
|
-
exports.calculate = calculate;
|
package/dist/ts2famix-cli.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
const fs = __importStar(require("fs"));
|
|
31
|
-
const yargs_1 = __importDefault(require("yargs"));
|
|
32
|
-
const analyze_1 = require("./analyze");
|
|
33
|
-
const ts_morph_1 = require("ts-morph");
|
|
34
|
-
const argv = yargs_1.default
|
|
35
|
-
.example(`ts2famix -i "path/to/project/**/*.ts" -o JSONModels/projectName.json`, 'Creates a JSON-format Famix model of typescript files.')
|
|
36
|
-
.example(`ts2famix -i path/to/tsconfig.json -o JSONModels/projectName.json`, 'Creates a JSON-format model of a typescript project.')
|
|
37
|
-
.alias('i', 'input')
|
|
38
|
-
.nargs('i', 1)
|
|
39
|
-
.alias('o', 'output')
|
|
40
|
-
.nargs('o', 1)
|
|
41
|
-
.demandOption('input').demandOption('output').parseSync();
|
|
42
|
-
const importer = new analyze_1.Importer();
|
|
43
|
-
let famixRep;
|
|
44
|
-
if (argv.input.endsWith('tsconfig.json')) {
|
|
45
|
-
const tsConfigFilePath = argv.input;
|
|
46
|
-
const project = new ts_morph_1.Project({
|
|
47
|
-
tsConfigFilePath
|
|
48
|
-
});
|
|
49
|
-
famixRep = importer.famixRepFromProject(project);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const paths = new Array();
|
|
53
|
-
paths.push(argv.input);
|
|
54
|
-
famixRep = importer.famixRepFromPaths(paths);
|
|
55
|
-
}
|
|
56
|
-
const jsonOutput = famixRep.getJSON();
|
|
57
|
-
const jsonFilePath = argv.output;
|
|
58
|
-
fs.writeFile(jsonFilePath, jsonOutput, (err) => {
|
|
59
|
-
if (err) {
|
|
60
|
-
throw err;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
console.info(`Created: ${jsonFilePath}`);
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const fs = __importStar(require("fs"));
|
|
30
|
-
const yargs_1 = __importDefault(require("yargs"));
|
|
31
|
-
const analyze_1 = require("./analyze");
|
|
32
|
-
const ts_morph_1 = require("ts-morph");
|
|
33
|
-
const importer = new analyze_1.Importer();
|
|
34
|
-
const argv = yargs_1.default
|
|
35
|
-
.example(`ts-node src/ts2famix-tsconfig.ts -i ../path/to/project/tsconfig.json -o JSONModels/projectName.json`, 'creates a JSON-format model of a typescript project')
|
|
36
|
-
.alias('i', 'input')
|
|
37
|
-
.nargs('i', 1)
|
|
38
|
-
.alias('o', 'output')
|
|
39
|
-
.nargs('o', 1)
|
|
40
|
-
.demandOption('input').demandOption('output').parseSync();
|
|
41
|
-
const tsConfigFilePath = argv.input;
|
|
42
|
-
const project = new ts_morph_1.Project({
|
|
43
|
-
tsConfigFilePath
|
|
44
|
-
});
|
|
45
|
-
const famixRep = importer.famixRepFromProject(project);
|
|
46
|
-
const jsonOutput = famixRep.getJSON();
|
|
47
|
-
const jsonFilePath = argv.output;
|
|
48
|
-
fs.writeFile(jsonFilePath, jsonOutput, (err) => {
|
|
49
|
-
if (err) {
|
|
50
|
-
throw err;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
console.info(`Created: ${jsonFilePath}`);
|
package/metrics.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
class ForMetrics {
|
|
2
|
-
public methodCyclomaticOne() {}
|
|
3
|
-
|
|
4
|
-
public methodCyclomaticFour() {
|
|
5
|
-
// make higher cyclomatic complexity
|
|
6
|
-
for (let i = 0; i < 50; i++) { // 2
|
|
7
|
-
for (let j = 0; j < 50; j++) { // 3
|
|
8
|
-
if (i < 10) {} // 4
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function functionCyclomaticOne() {}
|
|
15
|
-
|
|
16
|
-
function functionCyclomaticFour() {
|
|
17
|
-
// make higher cyclomatic complexity
|
|
18
|
-
for (let i = 0; i < 50; i++) { // 2
|
|
19
|
-
for (let j = 0; j < 50; j++) { // 3
|
|
20
|
-
if (i < 10) {} // 4
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|