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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +19 -2
  4. data/TODO +11 -0
  5. data/bin/churn_vs_complexity +5 -0
  6. data/lib/churn_vs_complexity/churn.rb +7 -2
  7. data/lib/churn_vs_complexity/cli.rb +21 -5
  8. data/lib/churn_vs_complexity/complexity/eslint_calculator.rb +34 -0
  9. data/lib/churn_vs_complexity/complexity/flog_calculator.rb +7 -6
  10. data/lib/churn_vs_complexity/complexity/pmd_calculator.rb +5 -2
  11. data/lib/churn_vs_complexity/complexity.rb +1 -0
  12. data/lib/churn_vs_complexity/concurrent_calculator.rb +2 -4
  13. data/lib/churn_vs_complexity/config.rb +81 -17
  14. data/lib/churn_vs_complexity/file_selector.rb +12 -1
  15. data/lib/churn_vs_complexity/git_date.rb +8 -1
  16. data/lib/churn_vs_complexity/serializer/csv.rb +14 -0
  17. data/lib/churn_vs_complexity/serializer/graph.rb +24 -0
  18. data/lib/churn_vs_complexity/serializer/pass_through.rb +21 -0
  19. data/lib/churn_vs_complexity/serializer/summary.rb +27 -0
  20. data/lib/churn_vs_complexity/serializer/summary_hash.rb +54 -0
  21. data/lib/churn_vs_complexity/serializer/timetravel/quality_calculator.rb +38 -0
  22. data/lib/churn_vs_complexity/serializer/timetravel/stats_calculator.rb +60 -0
  23. data/lib/churn_vs_complexity/serializer/timetravel.rb +103 -0
  24. data/lib/churn_vs_complexity/serializer.rb +7 -60
  25. data/lib/churn_vs_complexity/timetravel/traveller.rb +66 -0
  26. data/lib/churn_vs_complexity/timetravel/worktree.rb +56 -0
  27. data/lib/churn_vs_complexity/timetravel.rb +70 -0
  28. data/lib/churn_vs_complexity/version.rb +1 -1
  29. data/lib/churn_vs_complexity.rb +2 -0
  30. data/package-lock.json +6 -0
  31. data/tmp/eslint-support/complexity-calculator.js +51 -0
  32. data/tmp/eslint-support/package.json +11 -0
  33. data/tmp/template/graph.html +1 -4
  34. data/tmp/template/timetravel_graph.html +100 -0
  35. data/tmp/test-support/javascript/complex.js +43 -0
  36. data/tmp/test-support/javascript/moderate.js +12 -0
  37. data/tmp/test-support/javascript/simple.js +5 -0
  38. data/tmp/test-support/javascript/typescript-example.ts +26 -0
  39. data/tmp/timetravel/.keep +0 -0
  40. 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,12 @@
1
+ function fibonacci(n) {
2
+ if (n <= 1) return n;
3
+ return fibonacci(n - 1) + fibonacci(n - 2);
4
+ }
5
+
6
+ function printFibonacciSequence(length) {
7
+ for (let i = 0; i < length; i++) {
8
+ console.log(fibonacci(i));
9
+ }
10
+ }
11
+
12
+ printFibonacciSequence(10);
@@ -0,0 +1,5 @@
1
+ function greet(name) {
2
+ return `Hello, ${name}!`;
3
+ }
4
+
5
+ console.log(greet('World'));
@@ -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.2.0
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-09-20 00:00:00.000000000 Z
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