churn_vs_complexity 1.9.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +56 -0
- data/README.md +46 -23
- data/lib/churn_vs_complexity/analysis_scope.rb +20 -0
- data/lib/churn_vs_complexity/churn.rb +27 -9
- data/lib/churn_vs_complexity/cli/main.rb +58 -19
- data/lib/churn_vs_complexity/cli/parser.rb +85 -121
- data/lib/churn_vs_complexity/cli.rb +2 -3
- data/lib/churn_vs_complexity/complexity/flog_calculator.rb +0 -3
- data/lib/churn_vs_complexity/complexity/lizard_calculator.rb +64 -0
- data/lib/churn_vs_complexity/complexity.rb +1 -7
- data/lib/churn_vs_complexity/complexity_validator.rb +1 -16
- data/lib/churn_vs_complexity/concurrent_calculator.rb +20 -23
- data/lib/churn_vs_complexity/delta/checker.rb +35 -21
- data/lib/churn_vs_complexity/delta/commit_hydrator.rb +1 -1
- data/lib/churn_vs_complexity/delta/complexity_annotator.rb +23 -5
- data/lib/churn_vs_complexity/delta/config.rb +15 -16
- data/lib/churn_vs_complexity/delta/factory.rb +2 -2
- data/lib/churn_vs_complexity/delta/multi_checker.rb +24 -25
- data/lib/churn_vs_complexity/delta/serializer.rb +6 -4
- data/lib/churn_vs_complexity/delta.rb +11 -49
- data/lib/churn_vs_complexity/diff/checker.rb +10 -3
- data/lib/churn_vs_complexity/diff/config.rb +29 -20
- data/lib/churn_vs_complexity/file_selector.rb +63 -114
- data/lib/churn_vs_complexity/focus/config.rb +42 -32
- data/lib/churn_vs_complexity/focus/serializer.rb +17 -4
- data/lib/churn_vs_complexity/gate/config.rb +28 -25
- data/lib/churn_vs_complexity/git_strategy.rb +17 -12
- data/lib/churn_vs_complexity/hotspots/config.rb +29 -25
- data/lib/churn_vs_complexity/language_registry.rb +108 -0
- data/lib/churn_vs_complexity/language_validator.rb +1 -3
- data/lib/churn_vs_complexity/normal/config.rb +31 -100
- data/lib/churn_vs_complexity/normal/serializer/graph.rb +3 -2
- data/lib/churn_vs_complexity/normal/serializer/summary.rb +18 -14
- data/lib/churn_vs_complexity/normal/serializer/summary_hash.rb +15 -13
- data/lib/churn_vs_complexity/normal/serializer.rb +2 -1
- data/lib/churn_vs_complexity/normal.rb +17 -13
- data/lib/churn_vs_complexity/risk_classifier.rb +3 -19
- data/lib/churn_vs_complexity/timetravel/config.rb +34 -47
- data/lib/churn_vs_complexity/timetravel/schedule.rb +15 -0
- data/lib/churn_vs_complexity/timetravel/serializer/stats_calculator.rb +36 -32
- data/lib/churn_vs_complexity/timetravel/serializer.rb +16 -24
- data/lib/churn_vs_complexity/timetravel/traveller.rb +44 -15
- data/lib/churn_vs_complexity/timetravel.rb +36 -14
- data/lib/churn_vs_complexity/triage/checker.rb +24 -28
- data/lib/churn_vs_complexity/triage/collaborator_set.rb +11 -0
- data/lib/churn_vs_complexity/triage/config.rb +29 -26
- data/lib/churn_vs_complexity/triage.rb +1 -0
- data/lib/churn_vs_complexity/validator_set.rb +9 -0
- data/lib/churn_vs_complexity/version.rb +1 -1
- data/lib/churn_vs_complexity.rb +3 -0
- metadata +18 -22
- data/lib/churn_vs_complexity/complexity/eslint_calculator.rb +0 -40
- data/lib/churn_vs_complexity/complexity/go_calculator.rb +0 -48
- data/lib/churn_vs_complexity/complexity/kotlin_calculator.rb +0 -54
- data/lib/churn_vs_complexity/complexity/pmd/files_calculator.rb +0 -26
- data/lib/churn_vs_complexity/complexity/pmd/folder_calculator.rb +0 -20
- data/lib/churn_vs_complexity/complexity/pmd.rb +0 -54
- data/lib/churn_vs_complexity/complexity/python_calculator.rb +0 -50
- data/lib/churn_vs_complexity/complexity/rust_calculator.rb +0 -54
- data/lib/churn_vs_complexity/complexity/swift_calculator.rb +0 -54
- data/tmp/eslint-support/complexity-calculator.js +0 -51
- data/tmp/eslint-support/package.json +0 -11
- data/tmp/pmd-support/ruleset.xml +0 -21
|
@@ -4,46 +4,50 @@ module ChurnVsComplexity
|
|
|
4
4
|
module Timetravel
|
|
5
5
|
module Serializer
|
|
6
6
|
class StatsCalculator
|
|
7
|
-
# ['some_sha', { 'end_date' => '2024-01-01', 'values' => [[1, 2], [3, 4]] }]
|
|
8
7
|
def summaries(result)
|
|
9
|
-
observations = result
|
|
10
|
-
summary['end_date']
|
|
11
|
-
end.map { |entry| entry[1] }
|
|
12
|
-
|
|
8
|
+
observations = ordered_observations(result)
|
|
13
9
|
quality_calculator = QualityCalculator.new(**extrema(observations))
|
|
14
|
-
observations.map
|
|
15
|
-
end_date = o['end_date']
|
|
16
|
-
scores = o['values'].map do |(churn, complexity)|
|
|
17
|
-
alpha = quality_calculator.alpha_score(churn, complexity)
|
|
18
|
-
beta = quality_calculator.beta_score(churn, complexity)
|
|
19
|
-
[churn, complexity, alpha, beta]
|
|
20
|
-
end
|
|
21
|
-
{
|
|
22
|
-
'end_date' => end_date,
|
|
23
|
-
'mean_churn' => mean(scores.map { |s| s[0] }),
|
|
24
|
-
'median_churn' => median(scores.map { |s| s[0] }),
|
|
25
|
-
'mean_complexity' => mean(scores.map { |s| s[1] }),
|
|
26
|
-
'median_complexity' => median(scores.map { |s| s[1] }),
|
|
27
|
-
'mean_alpha_score' => mean(scores.map { |s| s[2] }),
|
|
28
|
-
'median_alpha_score' => median(scores.map { |s| s[2] }),
|
|
29
|
-
'mean_beta_score' => mean(scores.map { |s| s[3] }),
|
|
30
|
-
'median_beta_score' => median(scores.map { |s| s[3] }),
|
|
31
|
-
}
|
|
32
|
-
end
|
|
10
|
+
observations.map { |observation| summarize_observation(observation, quality_calculator) }
|
|
33
11
|
end
|
|
34
12
|
|
|
35
13
|
private
|
|
36
14
|
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
15
|
+
def ordered_observations(result)
|
|
16
|
+
sorted = result.sort_by { |_sha, summary| summary['end_date'] }
|
|
17
|
+
sorted.map { |entry| entry[1] }
|
|
18
|
+
end
|
|
41
19
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
def summarize_observation(observation, quality_calculator)
|
|
21
|
+
scores = score_values(observation['values'], quality_calculator)
|
|
22
|
+
{
|
|
23
|
+
'end_date' => observation['end_date'],
|
|
24
|
+
**series_stats('churn', scores.map { |s| s[0] }),
|
|
25
|
+
**series_stats('complexity', scores.map { |s| s[1] }),
|
|
26
|
+
**series_stats('alpha_score', scores.map { |s| s[2] }),
|
|
27
|
+
**series_stats('beta_score', scores.map { |s| s[3] }),
|
|
28
|
+
}
|
|
29
|
+
end
|
|
45
30
|
|
|
46
|
-
|
|
31
|
+
def score_values(values, quality_calculator)
|
|
32
|
+
values.map do |churn, complexity|
|
|
33
|
+
alpha = quality_calculator.alpha_score(churn, complexity)
|
|
34
|
+
beta = quality_calculator.beta_score(churn, complexity)
|
|
35
|
+
[churn, complexity, alpha, beta]
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def series_stats(name, series)
|
|
40
|
+
{ "mean_#{name}" => mean(series), "median_#{name}" => median(series) }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def extrema(observations)
|
|
44
|
+
values = observations.flat_map { |o| o['values'] }
|
|
45
|
+
churns = values.map(&:first)
|
|
46
|
+
complexities = values.map(&:last)
|
|
47
|
+
{
|
|
48
|
+
max_churn: churns.max, min_churn: churns.min,
|
|
49
|
+
max_complexity: complexities.max, min_complexity: complexities.min,
|
|
50
|
+
}
|
|
47
51
|
end
|
|
48
52
|
|
|
49
53
|
def mean(series)
|
|
@@ -20,28 +20,21 @@ module ChurnVsComplexity
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
module CSV
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
COLUMNS = {
|
|
24
|
+
'end_date' => 'Date',
|
|
25
|
+
'mean_churn' => 'Mean Churn',
|
|
26
|
+
'median_churn' => 'Median Churn',
|
|
27
|
+
'mean_complexity' => 'Mean Complexity',
|
|
28
|
+
'median_complexity' => 'Median Complexity',
|
|
29
|
+
'mean_alpha_score' => 'Mean Alpha Score',
|
|
30
|
+
'median_alpha_score' => 'Median Alpha Score',
|
|
31
|
+
'mean_beta_score' => 'Mean Beta Score',
|
|
32
|
+
'median_beta_score' => 'Median Beta Score',
|
|
33
|
+
}.freeze
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
summaries
|
|
28
|
-
|
|
29
|
-
'end_date' => 'Date',
|
|
30
|
-
'mean_churn' => 'Mean Churn',
|
|
31
|
-
'median_churn' => 'Median Churn',
|
|
32
|
-
'mean_complexity' => 'Mean Complexity',
|
|
33
|
-
'median_complexity' => 'Median Complexity',
|
|
34
|
-
'mean_alpha_score' => 'Mean Alpha Score',
|
|
35
|
-
'median_alpha_score' => 'Median Alpha Score',
|
|
36
|
-
'mean_beta_score' => 'Mean Beta Score',
|
|
37
|
-
'median_beta_score' => 'Median Beta Score',
|
|
38
|
-
},
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
# 3. convert to csv
|
|
42
|
-
summaries.map do |summary|
|
|
43
|
-
"#{summary['end_date']},#{summary['mean_churn']},#{summary['median_churn']},#{summary['mean_complexity']},#{summary['median_complexity']},#{summary['mean_alpha_score']},#{summary['median_alpha_score']},#{summary['mean_beta_score']},#{summary['median_beta_score']}"
|
|
44
|
-
end.join("\n")
|
|
35
|
+
def self.serialize(result)
|
|
36
|
+
rows = [COLUMNS, *Serializer.summaries(result)]
|
|
37
|
+
rows.map { |row| row.values_at(*COLUMNS.keys).join(',') }.join("\n")
|
|
45
38
|
end
|
|
46
39
|
end
|
|
47
40
|
|
|
@@ -62,9 +55,8 @@ module ChurnVsComplexity
|
|
|
62
55
|
def serialize(result)
|
|
63
56
|
summaries = Serializer.summaries(result)
|
|
64
57
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
end.join(",\n") + "\n"
|
|
58
|
+
entries = summaries.map { |summary| JSON.dump(summary) }.join(",\n")
|
|
59
|
+
data = "#{entries}\n"
|
|
68
60
|
|
|
69
61
|
@template.gsub("// INSERT DATA\n", data)
|
|
70
62
|
.gsub('INSERT TITLE', title)
|
|
@@ -1,37 +1,66 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module ChurnVsComplexity
|
|
4
|
-
# TODO: unit test and integration test
|
|
5
4
|
module Timetravel
|
|
6
5
|
class Traveller
|
|
7
|
-
def initialize(
|
|
8
|
-
@
|
|
6
|
+
def initialize(schedule:, engine:, serializer:, factory:)
|
|
7
|
+
@schedule = schedule
|
|
9
8
|
@engine = engine
|
|
10
|
-
@jump_days = jump_days
|
|
11
9
|
@serializer = serializer
|
|
12
|
-
@git_period = git_period
|
|
13
10
|
@factory = factory
|
|
14
11
|
end
|
|
15
12
|
|
|
16
13
|
def check(folder:)
|
|
17
14
|
git_strategy = @factory.git_strategy(folder:)
|
|
18
|
-
commits = git_strategy
|
|
19
|
-
|
|
15
|
+
commits = resolve_commits(git_strategy)
|
|
20
16
|
chunked = make_chunks(commits)
|
|
21
|
-
work_on(chunked:, folder:, git_strategy:)
|
|
22
|
-
combined = chunked
|
|
23
|
-
|
|
17
|
+
pids = work_on(chunked:, folder:, git_strategy:)
|
|
18
|
+
combined = combine_results(chunked)
|
|
24
19
|
@serializer.serialize(combined)
|
|
20
|
+
ensure
|
|
21
|
+
wait_for(pids)
|
|
25
22
|
end
|
|
26
23
|
|
|
27
24
|
private
|
|
28
25
|
|
|
26
|
+
def resolve_commits(git_strategy)
|
|
27
|
+
git_strategy.resolve_commits_with_interval(
|
|
28
|
+
git_period: @schedule.git_period,
|
|
29
|
+
jump_days: @schedule.jump_days,
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def combine_results(chunked)
|
|
34
|
+
chunked.map { |c_and_p| read_result(c_and_p[:pipe]) }.reduce({}, :merge)
|
|
35
|
+
end
|
|
36
|
+
|
|
29
37
|
def work_on(chunked:, folder:, git_strategy:)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
schedule_work(worktree:, **c_and_p)
|
|
38
|
+
pids = []
|
|
39
|
+
chunked.each_with_index do |c_and_p, number|
|
|
40
|
+
pids << start_worker(c_and_p:, folder:, git_strategy:, number:)
|
|
34
41
|
end
|
|
42
|
+
pids
|
|
43
|
+
rescue StandardError
|
|
44
|
+
wait_for(pids)
|
|
45
|
+
raise
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def start_worker(c_and_p:, folder:, git_strategy:, number:)
|
|
49
|
+
worktree = @factory.worktree(root_folder: folder, git_strategy:, number:)
|
|
50
|
+
worktree.prepare
|
|
51
|
+
schedule_work(worktree:, **c_and_p)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def wait_for(pids)
|
|
55
|
+
return unless pids
|
|
56
|
+
|
|
57
|
+
pids.grep(Integer).each { |pid| wait_pid(pid) }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def wait_pid(pid)
|
|
61
|
+
Process.waitpid(pid)
|
|
62
|
+
rescue Errno::ECHILD
|
|
63
|
+
nil
|
|
35
64
|
end
|
|
36
65
|
|
|
37
66
|
def make_chunks(commits)
|
|
@@ -49,7 +78,7 @@ module ChurnVsComplexity
|
|
|
49
78
|
rescue StandardError
|
|
50
79
|
{}
|
|
51
80
|
end
|
|
52
|
-
pipe.each
|
|
81
|
+
pipe.each { |io| io.close unless io.closed? }
|
|
53
82
|
part
|
|
54
83
|
end
|
|
55
84
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative 'timetravel/schedule'
|
|
3
4
|
require_relative 'timetravel/traveller'
|
|
4
5
|
require_relative 'timetravel/worktree'
|
|
5
6
|
require_relative 'timetravel/config'
|
|
@@ -8,7 +9,6 @@ require_relative 'timetravel/factory'
|
|
|
8
9
|
|
|
9
10
|
module ChurnVsComplexity
|
|
10
11
|
module Timetravel
|
|
11
|
-
# TODO: unit test
|
|
12
12
|
module SerializerValidator
|
|
13
13
|
def self.validate!(serializer:)
|
|
14
14
|
raise ValidationError, 'Does not support --summary in --timetravel mode' \
|
|
@@ -18,11 +18,10 @@ module ChurnVsComplexity
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
# TODO: unit test
|
|
22
21
|
module RelativePeriodValidator
|
|
23
22
|
def self.validate!(relative_period:)
|
|
24
23
|
raise ValidationError, 'Relative period is required in timetravel mode' if relative_period.nil?
|
|
25
|
-
return if
|
|
24
|
+
return if %i[month quarter year].include?(relative_period)
|
|
26
25
|
|
|
27
26
|
raise ValidationError, "Invalid relative period #{relative_period}"
|
|
28
27
|
end
|
|
@@ -30,7 +29,6 @@ module ChurnVsComplexity
|
|
|
30
29
|
|
|
31
30
|
module SinceValidator
|
|
32
31
|
def self.validate!(since:)
|
|
33
|
-
# since can be nil, a date string or a keyword (:month, :quarter, :year)
|
|
34
32
|
return if since.nil?
|
|
35
33
|
|
|
36
34
|
raise ValidationError, "Invalid since value #{since}" unless since.is_a?(String)
|
|
@@ -50,17 +48,41 @@ module ChurnVsComplexity
|
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
def schedule(chunk:, pipe:)
|
|
53
|
-
fork do
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@worktree.checkout(sha)
|
|
57
|
-
result = @engine.check(folder: @worktree.folder)
|
|
58
|
-
[sha, result]
|
|
59
|
-
end
|
|
60
|
-
@worktree.remove
|
|
61
|
-
pipe[1].puts(JSON.dump(results))
|
|
62
|
-
pipe[1].close
|
|
51
|
+
pid = fork do
|
|
52
|
+
pipe[0].close unless pipe[0].closed?
|
|
53
|
+
run_child(chunk:, write_io: pipe[1])
|
|
63
54
|
end
|
|
55
|
+
pipe[1].close unless pipe[1].closed?
|
|
56
|
+
pid
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
def run_child(chunk:, write_io:)
|
|
62
|
+
removed = false
|
|
63
|
+
results = process_chunk(chunk)
|
|
64
|
+
payload = JSON.dump(results)
|
|
65
|
+
removed = true
|
|
66
|
+
@worktree.remove
|
|
67
|
+
write_io.puts(payload)
|
|
68
|
+
ensure
|
|
69
|
+
cleanup_child(write_io:, removed:)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def cleanup_child(write_io:, removed:)
|
|
73
|
+
@worktree.remove unless removed
|
|
74
|
+
write_io.close unless write_io.closed?
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def process_chunk(chunk)
|
|
78
|
+
chunk.to_h { |commit| evaluate_commit(commit) }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def evaluate_commit(commit)
|
|
82
|
+
sha = commit.sha
|
|
83
|
+
@worktree.checkout(sha)
|
|
84
|
+
result = @engine.check(folder: @worktree.folder)
|
|
85
|
+
[sha, result]
|
|
64
86
|
end
|
|
65
87
|
end
|
|
66
88
|
end
|
|
@@ -3,20 +3,19 @@
|
|
|
3
3
|
module ChurnVsComplexity
|
|
4
4
|
module Triage
|
|
5
5
|
class Checker
|
|
6
|
-
def initialize(
|
|
7
|
-
@
|
|
6
|
+
def initialize(scope:, serializer:, targets:, collaborators: CollaboratorSet.new)
|
|
7
|
+
@scope = scope
|
|
8
8
|
@serializer = serializer
|
|
9
9
|
@targets = targets
|
|
10
|
-
@
|
|
11
|
-
@excluded = excluded
|
|
10
|
+
@collaborators = collaborators
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
def check(folder: nil)
|
|
15
14
|
files, dirs = partition_targets
|
|
16
|
-
|
|
17
|
-
engine = build_engine(files
|
|
18
|
-
raw_result = engine.check(folder:)
|
|
19
|
-
@serializer.serialize(raw_result.merge(language: @language))
|
|
15
|
+
target_folder = resolve_folder(folder, files, dirs)
|
|
16
|
+
engine = build_engine(files)
|
|
17
|
+
raw_result = engine.check(folder: target_folder)
|
|
18
|
+
@serializer.serialize(raw_result.merge(language: @scope.language))
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
private
|
|
@@ -25,39 +24,36 @@ module ChurnVsComplexity
|
|
|
25
24
|
@targets.partition { |t| File.file?(t) }
|
|
26
25
|
end
|
|
27
26
|
|
|
28
|
-
def
|
|
27
|
+
def resolve_folder(folder, files, dirs)
|
|
28
|
+
return folder if folder
|
|
29
|
+
return dirs.first unless dirs.empty?
|
|
30
|
+
return File.dirname(files.first) unless files.empty?
|
|
31
|
+
|
|
32
|
+
'.'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def build_engine(files)
|
|
29
36
|
Engine.concurrent(
|
|
30
|
-
complexity: complexity_for(@language),
|
|
31
|
-
churn:
|
|
37
|
+
complexity: @collaborators.complexity || complexity_for(@scope.language),
|
|
38
|
+
churn: @collaborators.churn,
|
|
32
39
|
file_selector: select_files(files),
|
|
33
40
|
serializer: Normal::Serializer::None,
|
|
34
|
-
since: @
|
|
41
|
+
since: @scope.effective_since,
|
|
35
42
|
)
|
|
36
43
|
end
|
|
37
44
|
|
|
38
45
|
def select_files(files)
|
|
39
|
-
selector = file_selector_for(@language)
|
|
40
|
-
|
|
46
|
+
selector = @collaborators.file_selector || file_selector_for(@scope.language)
|
|
47
|
+
excluded = @scope.excluded
|
|
48
|
+
files.any? ? selector.predefined(included: files, excluded:) : selector.excluding(excluded)
|
|
41
49
|
end
|
|
42
50
|
|
|
43
51
|
def file_selector_for(language)
|
|
44
|
-
|
|
45
|
-
when :ruby then FileSelector::Ruby
|
|
46
|
-
when :java then FileSelector::Java
|
|
47
|
-
when :javascript then FileSelector::JavaScript
|
|
48
|
-
when :python then FileSelector::Python
|
|
49
|
-
when :go then FileSelector::Go
|
|
50
|
-
end
|
|
52
|
+
LanguageRegistry.file_selector_for(language)
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
def complexity_for(language)
|
|
54
|
-
|
|
55
|
-
when :ruby then Complexity::FlogCalculator
|
|
56
|
-
when :java then Complexity::PMD::FolderCalculator
|
|
57
|
-
when :javascript then Complexity::ESLintCalculator
|
|
58
|
-
when :python then Complexity::PythonCalculator
|
|
59
|
-
when :go then Complexity::GoCalculator
|
|
60
|
-
end
|
|
56
|
+
LanguageRegistry.complexity_for(language)
|
|
61
57
|
end
|
|
62
58
|
end
|
|
63
59
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ChurnVsComplexity
|
|
4
|
+
module Triage
|
|
5
|
+
CollaboratorSet = Data.define(:complexity, :churn, :file_selector) do
|
|
6
|
+
def initialize(complexity: nil, churn: Churn::GitCalculator, file_selector: nil)
|
|
7
|
+
super
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -3,44 +3,47 @@
|
|
|
3
3
|
module ChurnVsComplexity
|
|
4
4
|
module Triage
|
|
5
5
|
class Config
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
SUPPORTED_SERIALIZERS = %i[json].freeze
|
|
7
|
+
|
|
8
|
+
def self.from_options(options)
|
|
9
|
+
new(
|
|
10
|
+
scope: AnalysisScope.from_options(options),
|
|
11
|
+
serializer: options[:serializer] || :json,
|
|
12
|
+
targets: options.fetch(:targets, []),
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def initialize(scope:, serializer: :json, targets: [], validators: ValidatorSet.new)
|
|
17
|
+
@scope = scope
|
|
17
18
|
@serializer = serializer
|
|
18
19
|
@targets = targets
|
|
19
|
-
@
|
|
20
|
-
@excluded = excluded
|
|
21
|
-
@complexity_validator = complexity_validator
|
|
22
|
-
@since_validator = since_validator
|
|
23
|
-
@options = options
|
|
20
|
+
@validators = validators
|
|
24
21
|
end
|
|
25
22
|
|
|
26
23
|
def validate!
|
|
27
|
-
LanguageValidator.validate!(@language)
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
LanguageValidator.validate!(@scope.language)
|
|
25
|
+
validate_serializer!
|
|
26
|
+
validate_period!
|
|
27
|
+
@validators.complexity.validate!(@scope.language)
|
|
30
28
|
end
|
|
31
29
|
|
|
32
30
|
def checker
|
|
33
|
-
Checker.new(
|
|
34
|
-
language: @language,
|
|
35
|
-
serializer: triage_serializer,
|
|
36
|
-
targets: @targets,
|
|
37
|
-
since: @since,
|
|
38
|
-
excluded: @excluded,
|
|
39
|
-
)
|
|
31
|
+
Checker.new(scope: @scope, serializer: triage_serializer, targets: @targets)
|
|
40
32
|
end
|
|
41
33
|
|
|
42
34
|
private
|
|
43
35
|
|
|
36
|
+
def validate_serializer!
|
|
37
|
+
return if SUPPORTED_SERIALIZERS.include?(@serializer)
|
|
38
|
+
|
|
39
|
+
raise ValidationError, "Unsupported serializer: #{@serializer}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def validate_period!
|
|
43
|
+
@validators.since.validate!(since: @scope.since, relative_period: @scope.relative_period)
|
|
44
|
+
Normal::RelativePeriodValidator.validate!(relative_period: @scope.relative_period)
|
|
45
|
+
end
|
|
46
|
+
|
|
44
47
|
def triage_serializer
|
|
45
48
|
case @serializer
|
|
46
49
|
when :json
|
data/lib/churn_vs_complexity.rb
CHANGED
|
@@ -26,11 +26,14 @@ require_relative 'churn_vs_complexity/engine'
|
|
|
26
26
|
require_relative 'churn_vs_complexity/concurrent_calculator'
|
|
27
27
|
require_relative 'churn_vs_complexity/file_selector'
|
|
28
28
|
require_relative 'churn_vs_complexity/complexity'
|
|
29
|
+
require_relative 'churn_vs_complexity/language_registry'
|
|
29
30
|
require_relative 'churn_vs_complexity/churn'
|
|
30
31
|
require_relative 'churn_vs_complexity/cli'
|
|
31
32
|
require_relative 'churn_vs_complexity/git_date'
|
|
32
33
|
require_relative 'churn_vs_complexity/complexity_validator'
|
|
33
34
|
require_relative 'churn_vs_complexity/language_validator'
|
|
35
|
+
require_relative 'churn_vs_complexity/analysis_scope'
|
|
36
|
+
require_relative 'churn_vs_complexity/validator_set'
|
|
34
37
|
require_relative 'churn_vs_complexity/git_strategy'
|
|
35
38
|
require_relative 'churn_vs_complexity/gamma_score'
|
|
36
39
|
require_relative 'churn_vs_complexity/risk_classifier'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: churn_vs_complexity
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik T. Madsen
|
|
@@ -15,33 +15,35 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '4.
|
|
18
|
+
version: '4.10'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '4.
|
|
25
|
+
version: '4.10'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: git
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '6.0'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '
|
|
39
|
+
version: '6.0'
|
|
40
40
|
description: Correlates file churn (how often files change) with complexity scores
|
|
41
|
-
to identify refactoring hotspots
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
to identify refactoring hotspots across 25 languages (Ruby via Flog plus 24 languages
|
|
42
|
+
via Lizard, including Java, JavaScript/TypeScript, Python, Go, Kotlin, Rust, Swift,
|
|
43
|
+
C/C++, C#, Objective-C, PHP, and Scala). Modes include hotspots ranking, triage
|
|
44
|
+
assessment, CI quality gate, diff comparison, focus sessions, delta analysis, and
|
|
45
|
+
timetravel history. Inspired by Michael Feathers' article "Getting Empirical about
|
|
46
|
+
Refactoring".
|
|
45
47
|
email:
|
|
46
48
|
- beatmadsen@gmail.com
|
|
47
49
|
executables:
|
|
@@ -54,21 +56,14 @@ files:
|
|
|
54
56
|
- README.md
|
|
55
57
|
- bin/churn_vs_complexity
|
|
56
58
|
- lib/churn_vs_complexity.rb
|
|
59
|
+
- lib/churn_vs_complexity/analysis_scope.rb
|
|
57
60
|
- lib/churn_vs_complexity/churn.rb
|
|
58
61
|
- lib/churn_vs_complexity/cli.rb
|
|
59
62
|
- lib/churn_vs_complexity/cli/main.rb
|
|
60
63
|
- lib/churn_vs_complexity/cli/parser.rb
|
|
61
64
|
- lib/churn_vs_complexity/complexity.rb
|
|
62
|
-
- lib/churn_vs_complexity/complexity/eslint_calculator.rb
|
|
63
65
|
- lib/churn_vs_complexity/complexity/flog_calculator.rb
|
|
64
|
-
- lib/churn_vs_complexity/complexity/
|
|
65
|
-
- lib/churn_vs_complexity/complexity/kotlin_calculator.rb
|
|
66
|
-
- lib/churn_vs_complexity/complexity/pmd.rb
|
|
67
|
-
- lib/churn_vs_complexity/complexity/pmd/files_calculator.rb
|
|
68
|
-
- lib/churn_vs_complexity/complexity/pmd/folder_calculator.rb
|
|
69
|
-
- lib/churn_vs_complexity/complexity/python_calculator.rb
|
|
70
|
-
- lib/churn_vs_complexity/complexity/rust_calculator.rb
|
|
71
|
-
- lib/churn_vs_complexity/complexity/swift_calculator.rb
|
|
66
|
+
- lib/churn_vs_complexity/complexity/lizard_calculator.rb
|
|
72
67
|
- lib/churn_vs_complexity/complexity_validator.rb
|
|
73
68
|
- lib/churn_vs_complexity/concurrent_calculator.rb
|
|
74
69
|
- lib/churn_vs_complexity/delta.rb
|
|
@@ -100,6 +95,7 @@ files:
|
|
|
100
95
|
- lib/churn_vs_complexity/hotspots/checker.rb
|
|
101
96
|
- lib/churn_vs_complexity/hotspots/config.rb
|
|
102
97
|
- lib/churn_vs_complexity/hotspots/serializer.rb
|
|
98
|
+
- lib/churn_vs_complexity/language_registry.rb
|
|
103
99
|
- lib/churn_vs_complexity/language_validator.rb
|
|
104
100
|
- lib/churn_vs_complexity/normal.rb
|
|
105
101
|
- lib/churn_vs_complexity/normal/config.rb
|
|
@@ -115,6 +111,7 @@ files:
|
|
|
115
111
|
- lib/churn_vs_complexity/timetravel.rb
|
|
116
112
|
- lib/churn_vs_complexity/timetravel/config.rb
|
|
117
113
|
- lib/churn_vs_complexity/timetravel/factory.rb
|
|
114
|
+
- lib/churn_vs_complexity/timetravel/schedule.rb
|
|
118
115
|
- lib/churn_vs_complexity/timetravel/serializer.rb
|
|
119
116
|
- lib/churn_vs_complexity/timetravel/serializer/quality_calculator.rb
|
|
120
117
|
- lib/churn_vs_complexity/timetravel/serializer/stats_calculator.rb
|
|
@@ -122,12 +119,11 @@ files:
|
|
|
122
119
|
- lib/churn_vs_complexity/timetravel/worktree.rb
|
|
123
120
|
- lib/churn_vs_complexity/triage.rb
|
|
124
121
|
- lib/churn_vs_complexity/triage/checker.rb
|
|
122
|
+
- lib/churn_vs_complexity/triage/collaborator_set.rb
|
|
125
123
|
- lib/churn_vs_complexity/triage/config.rb
|
|
126
124
|
- lib/churn_vs_complexity/triage/serializer.rb
|
|
125
|
+
- lib/churn_vs_complexity/validator_set.rb
|
|
127
126
|
- lib/churn_vs_complexity/version.rb
|
|
128
|
-
- tmp/eslint-support/complexity-calculator.js
|
|
129
|
-
- tmp/eslint-support/package.json
|
|
130
|
-
- tmp/pmd-support/ruleset.xml
|
|
131
127
|
- tmp/template/graph.html
|
|
132
128
|
- tmp/template/timetravel_graph.html
|
|
133
129
|
homepage: https://github.com/beatmadsen/churn_vs_complexity
|
|
@@ -151,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
151
147
|
- !ruby/object:Gem::Version
|
|
152
148
|
version: '0'
|
|
153
149
|
requirements: []
|
|
154
|
-
rubygems_version: 4.0.
|
|
150
|
+
rubygems_version: 4.0.20
|
|
155
151
|
specification_version: 4
|
|
156
152
|
summary: Analyse churn vs complexity to find refactoring hotspots, gate CI quality,
|
|
157
153
|
triage risky files, and track codebase health over time.
|