churn_vs_complexity 1.8.0 → 2.0.0

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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +95 -0
  3. data/README.md +46 -23
  4. data/bin/churn_vs_complexity +6 -1
  5. data/lib/churn_vs_complexity/analysis_scope.rb +20 -0
  6. data/lib/churn_vs_complexity/churn.rb +41 -8
  7. data/lib/churn_vs_complexity/cli/main.rb +58 -19
  8. data/lib/churn_vs_complexity/cli/parser.rb +85 -121
  9. data/lib/churn_vs_complexity/cli.rb +2 -3
  10. data/lib/churn_vs_complexity/complexity/flog_calculator.rb +0 -3
  11. data/lib/churn_vs_complexity/complexity/lizard_calculator.rb +64 -0
  12. data/lib/churn_vs_complexity/complexity.rb +1 -7
  13. data/lib/churn_vs_complexity/complexity_validator.rb +1 -16
  14. data/lib/churn_vs_complexity/concurrent_calculator.rb +20 -23
  15. data/lib/churn_vs_complexity/delta/checker.rb +35 -21
  16. data/lib/churn_vs_complexity/delta/commit_hydrator.rb +1 -1
  17. data/lib/churn_vs_complexity/delta/complexity_annotator.rb +23 -5
  18. data/lib/churn_vs_complexity/delta/config.rb +15 -16
  19. data/lib/churn_vs_complexity/delta/factory.rb +2 -2
  20. data/lib/churn_vs_complexity/delta/multi_checker.rb +24 -25
  21. data/lib/churn_vs_complexity/delta/serializer.rb +7 -4
  22. data/lib/churn_vs_complexity/delta.rb +11 -49
  23. data/lib/churn_vs_complexity/diff/checker.rb +10 -3
  24. data/lib/churn_vs_complexity/diff/config.rb +29 -20
  25. data/lib/churn_vs_complexity/file_selector.rb +63 -114
  26. data/lib/churn_vs_complexity/focus/config.rb +42 -32
  27. data/lib/churn_vs_complexity/focus/serializer.rb +17 -4
  28. data/lib/churn_vs_complexity/gate/config.rb +35 -25
  29. data/lib/churn_vs_complexity/gate/serializer.rb +9 -2
  30. data/lib/churn_vs_complexity/git_strategy.rb +29 -10
  31. data/lib/churn_vs_complexity/hotspots/config.rb +29 -25
  32. data/lib/churn_vs_complexity/language_registry.rb +108 -0
  33. data/lib/churn_vs_complexity/language_validator.rb +1 -3
  34. data/lib/churn_vs_complexity/normal/config.rb +31 -100
  35. data/lib/churn_vs_complexity/normal/serializer/graph.rb +3 -2
  36. data/lib/churn_vs_complexity/normal/serializer/summary.rb +18 -14
  37. data/lib/churn_vs_complexity/normal/serializer/summary_hash.rb +36 -21
  38. data/lib/churn_vs_complexity/normal/serializer.rb +2 -1
  39. data/lib/churn_vs_complexity/normal.rb +17 -13
  40. data/lib/churn_vs_complexity/risk_classifier.rb +3 -19
  41. data/lib/churn_vs_complexity/timetravel/config.rb +34 -47
  42. data/lib/churn_vs_complexity/timetravel/schedule.rb +15 -0
  43. data/lib/churn_vs_complexity/timetravel/serializer/stats_calculator.rb +36 -32
  44. data/lib/churn_vs_complexity/timetravel/serializer.rb +16 -24
  45. data/lib/churn_vs_complexity/timetravel/traveller.rb +46 -15
  46. data/lib/churn_vs_complexity/timetravel.rb +36 -14
  47. data/lib/churn_vs_complexity/triage/checker.rb +24 -28
  48. data/lib/churn_vs_complexity/triage/collaborator_set.rb +11 -0
  49. data/lib/churn_vs_complexity/triage/config.rb +29 -26
  50. data/lib/churn_vs_complexity/triage.rb +1 -0
  51. data/lib/churn_vs_complexity/validator_set.rb +9 -0
  52. data/lib/churn_vs_complexity/version.rb +1 -1
  53. data/lib/churn_vs_complexity.rb +3 -0
  54. metadata +18 -59
  55. data/.devcontainer/devcontainer.json +0 -26
  56. data/.rubocop.yml +0 -25
  57. data/CLAUDE.md +0 -60
  58. data/Dockerfile +0 -34
  59. data/Dockerfile.dev +0 -27
  60. data/Rakefile +0 -6
  61. data/TODO +0 -11
  62. data/lib/churn_vs_complexity/complexity/eslint_calculator.rb +0 -40
  63. data/lib/churn_vs_complexity/complexity/go_calculator.rb +0 -48
  64. data/lib/churn_vs_complexity/complexity/kotlin_calculator.rb +0 -54
  65. data/lib/churn_vs_complexity/complexity/pmd/files_calculator.rb +0 -26
  66. data/lib/churn_vs_complexity/complexity/pmd/folder_calculator.rb +0 -20
  67. data/lib/churn_vs_complexity/complexity/pmd.rb +0 -54
  68. data/lib/churn_vs_complexity/complexity/python_calculator.rb +0 -50
  69. data/lib/churn_vs_complexity/complexity/rust_calculator.rb +0 -54
  70. data/lib/churn_vs_complexity/complexity/swift_calculator.rb +0 -54
  71. data/package-lock.json +0 -6
  72. data/tmp/eslint-support/complexity-calculator.js +0 -51
  73. data/tmp/eslint-support/package.json +0 -11
  74. data/tmp/pmd-support/ruleset.xml +0 -21
  75. data/tmp/test-support/delta/ruby-summary.txt +0 -55
  76. data/tmp/test-support/delta/ruby.csv +0 -12
  77. data/tmp/test-support/go/main.go +0 -11
  78. data/tmp/test-support/go/utils.go +0 -13
  79. data/tmp/test-support/java/small-example/src/main/java/org/example/Main.java +0 -10
  80. data/tmp/test-support/java/small-example/src/main/java/org/example/spice/Checker.java +0 -28
  81. data/tmp/test-support/javascript/complex.js +0 -43
  82. data/tmp/test-support/javascript/moderate.js +0 -12
  83. data/tmp/test-support/javascript/simple.js +0 -5
  84. data/tmp/test-support/javascript/typescript-example.ts +0 -26
  85. data/tmp/test-support/kotlin/Main.kt +0 -7
  86. data/tmp/test-support/kotlin/Utils.kt +0 -11
  87. data/tmp/test-support/python/example.py +0 -6
  88. data/tmp/test-support/python/utils.py +0 -9
  89. data/tmp/test-support/rust/main.rs +0 -7
  90. data/tmp/test-support/rust/utils.rs +0 -20
  91. data/tmp/test-support/swift/main.swift +0 -7
  92. data/tmp/test-support/swift/utils.swift +0 -24
  93. data/tmp/test-support/txt/abc.txt +0 -0
  94. data/tmp/test-support/txt/d.txt +0 -0
  95. data/tmp/test-support/txt/ef.txt +0 -0
  96. data/tmp/test-support/txt/ghij.txt +0 -0
  97. data/tmp/test-support/txt/klm.txt +0 -0
  98. data/tmp/test-support/txt/nopq.txt +0 -0
  99. data/tmp/test-support/txt/r.txt +0 -0
  100. data/tmp/test-support/txt/st.txt +0 -0
  101. data/tmp/test-support/txt/uvx.txt +0 -0
  102. data/tmp/test-support/txt/yz.txt +0 -0
  103. data/tmp/timetravel/.keep +0 -0
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'pmd/folder_calculator'
4
- require_relative 'pmd/files_calculator'
5
-
6
- module ChurnVsComplexity
7
- module Complexity
8
- module PMD
9
- CONCURRENCY = Etc.nprocessors
10
-
11
- class << self
12
- def resolve_ruleset_path
13
- ruleset_path = File.join(gem_root, 'tmp', 'pmd-support', 'ruleset.xml')
14
- raise "ruleset.xml not found in #{ruleset_path}" unless File.exist?(ruleset_path)
15
-
16
- ruleset_path
17
- end
18
-
19
- def resolve_cache_path(*components)
20
- File.join(ChurnVsComplexity.tmp_dir_path(*components), 'pmd', 'pmd-cache')
21
- end
22
-
23
- def check_dependencies!
24
- `pmd --help`
25
- rescue StandardError
26
- raise Error, 'Could not execute PMD using command pmd'
27
- end
28
-
29
- private
30
-
31
- def gem_root = ROOT_PATH
32
- end
33
-
34
- class Parser
35
- def self.empty_result = {}
36
-
37
- def parse(output)
38
- doc = JSON.parse(output)
39
- doc['files'].each_with_object({}) do |file, result|
40
- result[file['filename']] =
41
- file['violations'].sum { |violation| extract_complexity(violation) }
42
- end
43
- end
44
-
45
- private
46
-
47
- def extract_complexity(violation)
48
- # Find text 'total cyclomatic complexity of <number>'
49
- violation['description'].match(/total cyclomatic complexity of (\d+)/)[1].to_i
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'open3'
5
-
6
- module ChurnVsComplexity
7
- module Complexity
8
- module PythonCalculator
9
- class << self
10
- attr_writer :command_runner
11
-
12
- def folder_based? = false
13
-
14
- def calculate(files:)
15
- json_output = run_radon(files)
16
- parse_radon_output(json_output, files:)
17
- end
18
-
19
- def parse_radon_output(json_output, files:)
20
- data = JSON.parse(json_output)
21
- files.to_h do |file|
22
- blocks = data[file] || []
23
- total = blocks.sum { |b| b['complexity'] }
24
- [file, total]
25
- end
26
- end
27
-
28
- def check_dependencies!
29
- command_runner.call('radon --version 2>&1')
30
- rescue Errno::ENOENT
31
- raise Error, 'Needs radon installed (pip install radon)'
32
- end
33
-
34
- private
35
-
36
- def command_runner
37
- @command_runner || Open3.method(:capture2)
38
- end
39
-
40
- def run_radon(files)
41
- files_arg = files.map { |f| "'#{f}'" }.join(' ')
42
- stdout, status = command_runner.call("radon cc #{files_arg} -j")
43
- raise Error, "radon failed (exit #{status.exitstatus}). Is it installed?" unless status.success?
44
-
45
- stdout
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'open3'
4
-
5
- module ChurnVsComplexity
6
- module Complexity
7
- module RustCalculator
8
- class << self
9
- attr_writer :command_runner
10
-
11
- def folder_based? = false
12
-
13
- def calculate(files:)
14
- csv_output = run_lizard(files)
15
- parse_lizard_output(csv_output, files:)
16
- end
17
-
18
- # Lizard CSV format: NLOC,CCN,tokens,params,length,"loc","file","func","long_func",start,end
19
- LIZARD_LINE_PATTERN = /^\d+,(\d+),\d+,\d+,\d+,"[^"]*","([^"]*)"/
20
-
21
- def parse_lizard_output(csv_output, files:)
22
- scores = Hash.new(0)
23
- csv_output.each_line do |line|
24
- match = line.match(LIZARD_LINE_PATTERN)
25
- next unless match
26
-
27
- scores[match[2]] += match[1].to_i
28
- end
29
- files.to_h { |file| [file, scores[file] || 0] }
30
- end
31
-
32
- def check_dependencies!
33
- command_runner.call('lizard --version 2>&1')
34
- rescue Errno::ENOENT
35
- raise Error, 'Needs lizard installed (pip install lizard)'
36
- end
37
-
38
- private
39
-
40
- def command_runner
41
- @command_runner || Open3.method(:capture2)
42
- end
43
-
44
- def run_lizard(files)
45
- files_arg = files.map { |f| "'#{f}'" }.join(' ')
46
- stdout, status = command_runner.call("lizard --csv #{files_arg}")
47
- raise Error, "lizard failed (exit #{status.exitstatus}). Is it installed?" unless status.success?
48
-
49
- stdout
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'open3'
4
-
5
- module ChurnVsComplexity
6
- module Complexity
7
- module SwiftCalculator
8
- class << self
9
- attr_writer :command_runner
10
-
11
- def folder_based? = false
12
-
13
- def calculate(files:)
14
- csv_output = run_lizard(files)
15
- parse_lizard_output(csv_output, files:)
16
- end
17
-
18
- # Lizard CSV format: NLOC,CCN,tokens,params,length,"loc","file","func","long_func",start,end
19
- LIZARD_LINE_PATTERN = /^\d+,(\d+),\d+,\d+,\d+,"[^"]*","([^"]*)"/
20
-
21
- def parse_lizard_output(csv_output, files:)
22
- scores = Hash.new(0)
23
- csv_output.each_line do |line|
24
- match = line.match(LIZARD_LINE_PATTERN)
25
- next unless match
26
-
27
- scores[match[2]] += match[1].to_i
28
- end
29
- files.to_h { |file| [file, scores[file] || 0] }
30
- end
31
-
32
- def check_dependencies!
33
- command_runner.call('lizard --version 2>&1')
34
- rescue Errno::ENOENT
35
- raise Error, 'Needs lizard installed (pip install lizard)'
36
- end
37
-
38
- private
39
-
40
- def command_runner
41
- @command_runner || Open3.method(:capture2)
42
- end
43
-
44
- def run_lizard(files)
45
- files_arg = files.map { |f| "'#{f}'" }.join(' ')
46
- stdout, status = command_runner.call("lizard --csv #{files_arg}")
47
- raise Error, "lizard failed (exit #{status.exitstatus}). Is it installed?" unless status.success?
48
-
49
- stdout
50
- end
51
- end
52
- end
53
- end
54
- end
data/package-lock.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "name": "churn_vs_complexity",
3
- "lockfileVersion": 3,
4
- "requires": true,
5
- "packages": {}
6
- }
@@ -1,51 +0,0 @@
1
- import { ESLint } from 'eslint';
2
-
3
- import eslint from '@eslint/js';
4
- import tseslint from 'typescript-eslint';
5
-
6
- async function analyzeComplexity(files) {
7
- const overrideConfig = tseslint.config(
8
- eslint.configs.recommended,
9
- ...tseslint.configs.recommended,
10
- {
11
- rules: {
12
- 'complexity': ['warn', 0],
13
- },
14
-
15
- }
16
- );
17
-
18
- const linter = new ESLint({
19
- overrideConfigFile: true,
20
- overrideConfig,
21
- cwd: '/',
22
- });
23
-
24
- try {
25
- const results = await linter.lintFiles(files);
26
- const complexityResults = results.map(result => {
27
- const messages = result.messages.filter(msg => msg.ruleId === 'complexity');
28
- const complexity = messages.reduce((sum, msg) => {
29
- const complexityValue = parseInt(msg.message.match(/\d+/)[0], 10);
30
- return sum + complexityValue;
31
- }, 0);
32
-
33
- if (complexity === 0) {
34
- console.error("File has no complexity", result);
35
- }
36
-
37
- return {
38
- file: result.filePath,
39
- complexity,
40
- };
41
- });
42
-
43
- console.log(JSON.stringify(complexityResults));
44
- } catch (error) {
45
- console.error('Error during analysis:', error);
46
- process.exit(1);
47
- }
48
- }
49
-
50
- const files = JSON.parse(process.argv[2]);
51
- analyzeComplexity(files);
@@ -1,11 +0,0 @@
1
- {
2
- "type": "module",
3
- "dependencies": {
4
- "eslint-plugin-complexity": "^1.0.2",
5
- "@eslint/js": "^9.11.1",
6
- "@types/eslint__js": "^8.42.3",
7
- "eslint": "^9.11.1",
8
- "typescript": "^5.6.2",
9
- "typescript-eslint": "^8.7.0"
10
- }
11
- }
@@ -1,21 +0,0 @@
1
- <?xml version="1.0"?>
2
-
3
- <ruleset name="Rules for churn vs complexity"
4
- xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
5
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
- xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
7
-
8
- <description>
9
- Find cyclomatic complexity in java files
10
- </description>
11
-
12
- <rule ref="category/java/design.xml/CyclomaticComplexity">
13
- <properties>
14
- <property name="classReportLevel" value="1"/>
15
- <!-- We only want one report pr class -->
16
- <property name="methodReportLevel" value="1000000"/>
17
- <property name="cycloOptions" value=""/>
18
- </properties>
19
- </rule>
20
-
21
- </ruleset>
@@ -1,55 +0,0 @@
1
- Commit: b20a9bddd04afb9c7a736cf4530fd3188b5f785e
2
- Parent: 4f3151f83e982eb8f2b8a4e7a7572a0af156c3c0
3
- Next: 8cdaac516365bd7007b9f755bbe6f6e86d8e13dd
4
-
5
-
6
- File, relative path: lib/churn_vs_complexity/serializer/timetravel.rb
7
- Type of change: modified
8
- Complexity: 58.34326171010786
9
-
10
- File, relative path: lib/churn_vs_complexity/serializer/timetravel/stats_calculator.rb
11
- Type of change: new
12
- Complexity: 80.35549194682164
13
-
14
- File, relative path: test/churn_vs_complexity/serializer/timetravel/quality_calculator_test.rb
15
- Type of change: modified
16
- Complexity: 13.054183368177016
17
-
18
- File, relative path: test/churn_vs_complexity/serializer/timetravel/stats_calculator_test.rb
19
- Type of change: new
20
- Complexity: 12.2198021565134
21
-
22
-
23
-
24
- Commit: 4f3151f83e982eb8f2b8a4e7a7572a0af156c3c0
25
- Parent: 83deeccf8aa40e46cd0ca7e2c603c9726633256e
26
- Next: b20a9bddd04afb9c7a736cf4530fd3188b5f785e
27
-
28
-
29
- File, relative path: lib/churn_vs_complexity/config.rb
30
- Type of change: modified
31
- Complexity: 70.26655854867414
32
-
33
- File, relative path: lib/churn_vs_complexity/serializer/pass_through.rb
34
- Type of change: new
35
- Complexity: 19.309088021254183
36
-
37
- File, relative path: lib/churn_vs_complexity/serializer/summary_hash.rb
38
- Type of change: modified
39
- Complexity: 89.25682464940157
40
-
41
- File, relative path: lib/churn_vs_complexity/serializer/timetravel.rb
42
- Type of change: modified
43
- Complexity: 131.0989019732436
44
-
45
- File, relative path: lib/churn_vs_complexity/serializer/timetravel/quality_calculator.rb
46
- Type of change: new
47
- Complexity: 23.324498016752965
48
-
49
- File, relative path: test/churn_vs_complexity/serializer/summary_hash_test.rb
50
- Type of change: modified
51
- Complexity: 14.396336540125482
52
-
53
- File, relative path: test/churn_vs_complexity/serializer/timetravel/quality_calculator_test.rb
54
- Type of change: new
55
- Complexity: 13.054183368177016
@@ -1,12 +0,0 @@
1
- Commit, Relative Path, Type of Change, Complexity
2
- b20a9bddd04afb9c7a736cf4530fd3188b5f785e, lib/churn_vs_complexity/serializer/timetravel.rb, modified, 58.34326171010786
3
- b20a9bddd04afb9c7a736cf4530fd3188b5f785e, lib/churn_vs_complexity/serializer/timetravel/stats_calculator.rb, new, 80.35549194682164
4
- b20a9bddd04afb9c7a736cf4530fd3188b5f785e, test/churn_vs_complexity/serializer/timetravel/quality_calculator_test.rb, modified, 13.054183368177016
5
- b20a9bddd04afb9c7a736cf4530fd3188b5f785e, test/churn_vs_complexity/serializer/timetravel/stats_calculator_test.rb, new, 12.2198021565134
6
- 4f3151f83e982eb8f2b8a4e7a7572a0af156c3c0, lib/churn_vs_complexity/config.rb, modified, 70.26655854867414
7
- 4f3151f83e982eb8f2b8a4e7a7572a0af156c3c0, lib/churn_vs_complexity/serializer/pass_through.rb, new, 19.309088021254183
8
- 4f3151f83e982eb8f2b8a4e7a7572a0af156c3c0, lib/churn_vs_complexity/serializer/summary_hash.rb, modified, 89.25682464940157
9
- 4f3151f83e982eb8f2b8a4e7a7572a0af156c3c0, lib/churn_vs_complexity/serializer/timetravel.rb, modified, 131.0989019732436
10
- 4f3151f83e982eb8f2b8a4e7a7572a0af156c3c0, lib/churn_vs_complexity/serializer/timetravel/quality_calculator.rb, new, 23.324498016752965
11
- 4f3151f83e982eb8f2b8a4e7a7572a0af156c3c0, test/churn_vs_complexity/serializer/summary_hash_test.rb, modified, 14.396336540125482
12
- 4f3151f83e982eb8f2b8a4e7a7572a0af156c3c0, test/churn_vs_complexity/serializer/timetravel/quality_calculator_test.rb, new, 13.054183368177016
@@ -1,11 +0,0 @@
1
- package main
2
-
3
- import "fmt"
4
-
5
- func main() {
6
- fmt.Println("Hello, world!")
7
- }
8
-
9
- func add(a, b int) int {
10
- return a + b
11
- }
@@ -1,13 +0,0 @@
1
- package main
2
-
3
- func calculateSum(numbers []int) int {
4
- total := 0
5
- for _, n := range numbers {
6
- total += n
7
- }
8
- return total
9
- }
10
-
11
- func isEven(n int) bool {
12
- return n%2 == 0
13
- }
@@ -1,10 +0,0 @@
1
- package org.example;
2
-
3
- import org.example.spice.Checker;
4
-
5
- public class Main {
6
- public static void main(String[] args) {
7
- new Checker().check();
8
- }
9
-
10
- }
@@ -1,28 +0,0 @@
1
- package org.example.spice;
2
-
3
- import java.util.Iterator;
4
- import java.util.PrimitiveIterator;
5
- import java.util.Random;
6
-
7
- public class Checker {
8
- public void check() {
9
- for (int j = 0; j < 3; j++) {
10
- var iter = tenRandomInts();
11
- while (iter.hasNext()) {
12
- var i = iter.nextInt();
13
- if (i < 100) {
14
- System.out.println("Bongo");
15
- } else if (i > 200) {
16
- System.out.println("Dingo");
17
- } else {
18
- System.out.println("Zapp");
19
- }
20
- }
21
- }
22
- }
23
-
24
- private static PrimitiveIterator.OfInt tenRandomInts() {
25
- var randomInts = new Random().ints();
26
- return randomInts.limit(10).iterator();
27
- }
28
- }
@@ -1,43 +0,0 @@
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));
@@ -1,12 +0,0 @@
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);
@@ -1,5 +0,0 @@
1
- function greet(name) {
2
- return `Hello, ${name}!`;
3
- }
4
-
5
- console.log(greet('World'));
@@ -1,26 +0,0 @@
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));
@@ -1,7 +0,0 @@
1
- fun main() {
2
- println("Hello, world!")
3
- }
4
-
5
- fun add(a: Int, b: Int): Int {
6
- return a + b
7
- }
@@ -1,11 +0,0 @@
1
- fun calculateSum(numbers: List<Int>): Int {
2
- var total = 0
3
- for (n in numbers) {
4
- total += n
5
- }
6
- return total
7
- }
8
-
9
- fun isEven(n: Int): Boolean {
10
- return n % 2 == 0
11
- }
@@ -1,6 +0,0 @@
1
- def hello():
2
- print("Hello, world!")
3
-
4
-
5
- def add(a, b):
6
- return a + b
@@ -1,9 +0,0 @@
1
- def calculate_sum(numbers):
2
- total = 0
3
- for n in numbers:
4
- total += n
5
- return total
6
-
7
-
8
- def is_even(n):
9
- return n % 2 == 0
@@ -1,7 +0,0 @@
1
- fn main() {
2
- println!("Hello, world!");
3
- }
4
-
5
- fn add(a: i32, b: i32) -> i32 {
6
- a + b
7
- }
@@ -1,20 +0,0 @@
1
- fn calculate_sum(numbers: &[i32]) -> i32 {
2
- let mut total = 0;
3
- for n in numbers {
4
- total += n;
5
- }
6
- total
7
- }
8
-
9
- fn classify(value: i32) -> &'static str {
10
- match value {
11
- 0 => "zero",
12
- 1..=10 => "low",
13
- 11..=100 => "medium",
14
- _ => "high",
15
- }
16
- }
17
-
18
- fn is_even(n: i32) -> bool {
19
- n % 2 == 0
20
- }
@@ -1,7 +0,0 @@
1
- func main() {
2
- print("Hello, world!")
3
- }
4
-
5
- func add(_ a: Int, _ b: Int) -> Int {
6
- return a + b
7
- }
@@ -1,24 +0,0 @@
1
- func calculateSum(_ numbers: [Int]) -> Int {
2
- var total = 0
3
- for n in numbers {
4
- total += n
5
- }
6
- return total
7
- }
8
-
9
- func classify(_ value: Int) -> String {
10
- switch value {
11
- case 0:
12
- return "zero"
13
- case 1...10:
14
- return "low"
15
- case 11...100:
16
- return "medium"
17
- default:
18
- return "high"
19
- }
20
- }
21
-
22
- func isEven(_ n: Int) -> Bool {
23
- return n % 2 == 0
24
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/tmp/timetravel/.keep DELETED
File without changes