churn_vs_complexity 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +19 -2
- data/TODO +11 -0
- data/bin/churn_vs_complexity +5 -0
- data/lib/churn_vs_complexity/churn.rb +7 -2
- data/lib/churn_vs_complexity/cli.rb +21 -5
- data/lib/churn_vs_complexity/complexity/eslint_calculator.rb +34 -0
- data/lib/churn_vs_complexity/complexity/flog_calculator.rb +7 -6
- data/lib/churn_vs_complexity/complexity/pmd_calculator.rb +5 -2
- data/lib/churn_vs_complexity/complexity.rb +1 -0
- data/lib/churn_vs_complexity/concurrent_calculator.rb +2 -4
- data/lib/churn_vs_complexity/config.rb +81 -17
- data/lib/churn_vs_complexity/file_selector.rb +12 -1
- data/lib/churn_vs_complexity/git_date.rb +8 -1
- data/lib/churn_vs_complexity/serializer/csv.rb +14 -0
- data/lib/churn_vs_complexity/serializer/graph.rb +24 -0
- data/lib/churn_vs_complexity/serializer/pass_through.rb +21 -0
- data/lib/churn_vs_complexity/serializer/summary.rb +27 -0
- data/lib/churn_vs_complexity/serializer/summary_hash.rb +54 -0
- data/lib/churn_vs_complexity/serializer/timetravel/quality_calculator.rb +38 -0
- data/lib/churn_vs_complexity/serializer/timetravel/stats_calculator.rb +60 -0
- data/lib/churn_vs_complexity/serializer/timetravel.rb +103 -0
- data/lib/churn_vs_complexity/serializer.rb +7 -60
- data/lib/churn_vs_complexity/timetravel/traveller.rb +66 -0
- data/lib/churn_vs_complexity/timetravel/worktree.rb +56 -0
- data/lib/churn_vs_complexity/timetravel.rb +70 -0
- data/lib/churn_vs_complexity/version.rb +1 -1
- data/lib/churn_vs_complexity.rb +2 -0
- data/package-lock.json +6 -0
- data/tmp/eslint-support/complexity-calculator.js +51 -0
- data/tmp/eslint-support/package.json +11 -0
- data/tmp/template/graph.html +1 -4
- data/tmp/template/timetravel_graph.html +100 -0
- data/tmp/test-support/javascript/complex.js +43 -0
- data/tmp/test-support/javascript/moderate.js +12 -0
- data/tmp/test-support/javascript/simple.js +5 -0
- data/tmp/test-support/javascript/typescript-example.ts +26 -0
- data/tmp/timetravel/.keep +0 -0
- metadata +24 -2
@@ -0,0 +1,43 @@
|
|
1
|
+
function analyzeNumber(num) {
|
2
|
+
let result = '';
|
3
|
+
|
4
|
+
if (num < 0) {
|
5
|
+
result += 'negative ';
|
6
|
+
} else if (num > 0) {
|
7
|
+
result += 'positive ';
|
8
|
+
} else {
|
9
|
+
return 'zero';
|
10
|
+
}
|
11
|
+
|
12
|
+
if (num % 2 === 0) {
|
13
|
+
result += 'even ';
|
14
|
+
} else {
|
15
|
+
result += 'odd ';
|
16
|
+
}
|
17
|
+
|
18
|
+
if (num % 3 === 0) {
|
19
|
+
result += 'divisible by 3 ';
|
20
|
+
}
|
21
|
+
|
22
|
+
if (num % 5 === 0) {
|
23
|
+
result += 'divisible by 5 ';
|
24
|
+
}
|
25
|
+
|
26
|
+
if (isPrime(num)) {
|
27
|
+
result += 'prime ';
|
28
|
+
}
|
29
|
+
|
30
|
+
return result.trim();
|
31
|
+
}
|
32
|
+
|
33
|
+
function isPrime(num) {
|
34
|
+
if (num <= 1) return false;
|
35
|
+
for (let i = 2; i <= Math.sqrt(num); i++) {
|
36
|
+
if (num % i === 0) return false;
|
37
|
+
}
|
38
|
+
return true;
|
39
|
+
}
|
40
|
+
|
41
|
+
console.log(analyzeNumber(17));
|
42
|
+
console.log(analyzeNumber(30));
|
43
|
+
console.log(analyzeNumber(-7));
|
@@ -0,0 +1,26 @@
|
|
1
|
+
interface Person {
|
2
|
+
name: string;
|
3
|
+
age: number;
|
4
|
+
}
|
5
|
+
|
6
|
+
function createGreeting(person: Person): string {
|
7
|
+
let greeting = `Hello, ${person.name}!`;
|
8
|
+
|
9
|
+
if (person.age < 18) {
|
10
|
+
greeting += " You're still a minor.";
|
11
|
+
} else if (person.age >= 18 && person.age < 65) {
|
12
|
+
greeting += " You're an adult.";
|
13
|
+
} else {
|
14
|
+
greeting += " You're a senior citizen.";
|
15
|
+
}
|
16
|
+
|
17
|
+
return greeting;
|
18
|
+
}
|
19
|
+
|
20
|
+
const alice: Person = { name: 'Alice', age: 30 };
|
21
|
+
const bob: Person = { name: 'Bob', age: 17 };
|
22
|
+
const charlie: Person = { name: 'Charlie', age: 70 };
|
23
|
+
|
24
|
+
console.log(createGreeting(alice));
|
25
|
+
console.log(createGreeting(bob));
|
26
|
+
console.log(createGreeting(charlie));
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: churn_vs_complexity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik T. Madsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flog
|
@@ -57,11 +57,13 @@ files:
|
|
57
57
|
- LICENSE.txt
|
58
58
|
- README.md
|
59
59
|
- Rakefile
|
60
|
+
- TODO
|
60
61
|
- bin/churn_vs_complexity
|
61
62
|
- lib/churn_vs_complexity.rb
|
62
63
|
- lib/churn_vs_complexity/churn.rb
|
63
64
|
- lib/churn_vs_complexity/cli.rb
|
64
65
|
- lib/churn_vs_complexity/complexity.rb
|
66
|
+
- lib/churn_vs_complexity/complexity/eslint_calculator.rb
|
65
67
|
- lib/churn_vs_complexity/complexity/flog_calculator.rb
|
66
68
|
- lib/churn_vs_complexity/complexity/pmd_calculator.rb
|
67
69
|
- lib/churn_vs_complexity/concurrent_calculator.rb
|
@@ -70,11 +72,30 @@ files:
|
|
70
72
|
- lib/churn_vs_complexity/file_selector.rb
|
71
73
|
- lib/churn_vs_complexity/git_date.rb
|
72
74
|
- lib/churn_vs_complexity/serializer.rb
|
75
|
+
- lib/churn_vs_complexity/serializer/csv.rb
|
76
|
+
- lib/churn_vs_complexity/serializer/graph.rb
|
77
|
+
- lib/churn_vs_complexity/serializer/pass_through.rb
|
78
|
+
- lib/churn_vs_complexity/serializer/summary.rb
|
79
|
+
- lib/churn_vs_complexity/serializer/summary_hash.rb
|
80
|
+
- lib/churn_vs_complexity/serializer/timetravel.rb
|
81
|
+
- lib/churn_vs_complexity/serializer/timetravel/quality_calculator.rb
|
82
|
+
- lib/churn_vs_complexity/serializer/timetravel/stats_calculator.rb
|
83
|
+
- lib/churn_vs_complexity/timetravel.rb
|
84
|
+
- lib/churn_vs_complexity/timetravel/traveller.rb
|
85
|
+
- lib/churn_vs_complexity/timetravel/worktree.rb
|
73
86
|
- lib/churn_vs_complexity/version.rb
|
87
|
+
- package-lock.json
|
88
|
+
- tmp/eslint-support/complexity-calculator.js
|
89
|
+
- tmp/eslint-support/package.json
|
74
90
|
- tmp/pmd-support/ruleset.xml
|
75
91
|
- tmp/template/graph.html
|
92
|
+
- tmp/template/timetravel_graph.html
|
76
93
|
- tmp/test-support/java/small-example/src/main/java/org/example/Main.java
|
77
94
|
- tmp/test-support/java/small-example/src/main/java/org/example/spice/Checker.java
|
95
|
+
- tmp/test-support/javascript/complex.js
|
96
|
+
- tmp/test-support/javascript/moderate.js
|
97
|
+
- tmp/test-support/javascript/simple.js
|
98
|
+
- tmp/test-support/javascript/typescript-example.ts
|
78
99
|
- tmp/test-support/txt/abc.txt
|
79
100
|
- tmp/test-support/txt/d.txt
|
80
101
|
- tmp/test-support/txt/ef.txt
|
@@ -85,6 +106,7 @@ files:
|
|
85
106
|
- tmp/test-support/txt/st.txt
|
86
107
|
- tmp/test-support/txt/uvx.txt
|
87
108
|
- tmp/test-support/txt/yz.txt
|
109
|
+
- tmp/timetravel/.keep
|
88
110
|
homepage: https://github.com/beatmadsen/churn_vs_complexity
|
89
111
|
licenses:
|
90
112
|
- MIT
|