churn_vs_complexity 1.6.2 → 1.7.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 +5 -0
- data/CLAUDE.md +1 -1
- data/README.md +6 -1
- data/lib/churn_vs_complexity/cli/parser.rb +4 -0
- data/lib/churn_vs_complexity/complexity/kotlin_calculator.rb +54 -0
- data/lib/churn_vs_complexity/complexity.rb +1 -0
- data/lib/churn_vs_complexity/complexity_validator.rb +2 -0
- data/lib/churn_vs_complexity/delta.rb +4 -0
- data/lib/churn_vs_complexity/file_selector.rb +12 -0
- data/lib/churn_vs_complexity/language_validator.rb +1 -1
- data/lib/churn_vs_complexity/normal/config.rb +8 -0
- data/lib/churn_vs_complexity/risk_classifier.rb +1 -0
- data/lib/churn_vs_complexity/version.rb +1 -1
- data/tmp/test-support/kotlin/Main.kt +7 -0
- data/tmp/test-support/kotlin/Utils.kt +11 -0
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbfecd03ad25cb8f79ae5b52564f591b122eab2b8ee13e3fe80d1d33883e2747
|
|
4
|
+
data.tar.gz: 4ba6ffb8794bb11c9e87103f26b481b9b6bb29230eb1c55fa7fff7c46aaa0687
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7463ac718037f9f8d13ba08d1c39b775557246f85bd3e29852ee573b1af55625026e792d239e3d38df118923f80b68d75243508f5dd98b6739bd1b80408fe20
|
|
7
|
+
data.tar.gz: 35358bac1704bc9bca9cb9204d053c3484d9aa5e4d1e378b0feb48e2236f014354494b8ddcd36d12d127865361add543f511e514bfa412d01f7b34f038fb1042
|
data/CHANGELOG.md
CHANGED
data/CLAUDE.md
CHANGED
|
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
4
4
|
|
|
5
5
|
## Project Overview
|
|
6
6
|
|
|
7
|
-
`churn_vs_complexity` is a Ruby gem that analyzes code quality by correlating file churn (how often files change) with complexity scores. It supports Ruby (via Flog), JavaScript/TypeScript (via ESLint),
|
|
7
|
+
`churn_vs_complexity` is a Ruby gem that analyzes code quality by correlating file churn (how often files change) with complexity scores. It supports Ruby (via Flog), JavaScript/TypeScript (via ESLint), Java (via PMD), Python (via Radon), Go (via gocognit), and Kotlin (via lizard). Requires Ruby >= 3.3.
|
|
8
8
|
|
|
9
9
|
## Commands
|
|
10
10
|
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# ChurnVsComplexity
|
|
4
4
|
|
|
5
|
-
Correlates file churn (how often files change) with complexity scores to identify refactoring hotspots and track codebase health over time. Supports Ruby, JavaScript/TypeScript, Java, Python, and
|
|
5
|
+
Correlates file churn (how often files change) with complexity scores to identify refactoring hotspots and track codebase health over time. Supports Ruby, JavaScript/TypeScript, Java, Python, Go, and Kotlin.
|
|
6
6
|
|
|
7
7
|
Modes include hotspots ranking, triage assessment, CI quality gate, diff comparison, focus sessions, and timetravel history.
|
|
8
8
|
|
|
@@ -33,6 +33,7 @@ External tool dependencies per language:
|
|
|
33
33
|
- **JavaScript/TypeScript**: Requires [Node.js](https://nodejs.org) (uses ESLint internally).
|
|
34
34
|
- **Python**: Requires [Radon](https://radon.readthedocs.io) on the search path as `radon`. Install with `pip install radon`.
|
|
35
35
|
- **Go**: Requires [gocyclo](https://github.com/fzipp/gocyclo) on the search path. Install with `go install github.com/fzipp/gocyclo/cmd/gocyclo@latest`.
|
|
36
|
+
- **Kotlin**: Requires [lizard](https://github.com/terryyin/lizard) on the search path. Install with `pip install lizard`.
|
|
36
37
|
|
|
37
38
|
## Usage
|
|
38
39
|
|
|
@@ -48,6 +49,7 @@ Languages:
|
|
|
48
49
|
Check complexity of javascript and typescript files
|
|
49
50
|
--python Check complexity of python files
|
|
50
51
|
--go Check complexity of go files
|
|
52
|
+
--kotlin Check complexity of kotlin files
|
|
51
53
|
|
|
52
54
|
Modes (mutually exclusive):
|
|
53
55
|
--timetravel N Calculate summary for all commits at intervals of N days throughout project history or from the date specified with --since
|
|
@@ -121,6 +123,9 @@ churn_vs_complexity --java -m --since 2019-03-01 --timetravel 30 --graph my_java
|
|
|
121
123
|
|
|
122
124
|
# Analyse complexity of specific commits
|
|
123
125
|
churn_vs_complexity --js --delta HEAD --summary my_js_project
|
|
126
|
+
|
|
127
|
+
# Kotlin project hotspots
|
|
128
|
+
churn_vs_complexity --kotlin --hotspots my_kotlin_project
|
|
124
129
|
```
|
|
125
130
|
|
|
126
131
|
## Development
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'open3'
|
|
4
|
+
|
|
5
|
+
module ChurnVsComplexity
|
|
6
|
+
module Complexity
|
|
7
|
+
module KotlinCalculator
|
|
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+,"[^"]*","([^"]*)"/.freeze
|
|
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
|
|
@@ -5,6 +5,7 @@ require_relative 'complexity/flog_calculator'
|
|
|
5
5
|
require_relative 'complexity/eslint_calculator'
|
|
6
6
|
require_relative 'complexity/python_calculator'
|
|
7
7
|
require_relative 'complexity/go_calculator'
|
|
8
|
+
require_relative 'complexity/kotlin_calculator'
|
|
8
9
|
|
|
9
10
|
module ChurnVsComplexity
|
|
10
11
|
module Complexity
|
|
@@ -38,6 +38,8 @@ module ChurnVsComplexity
|
|
|
38
38
|
FileSelector::Python.predefined(included:, excluded:)
|
|
39
39
|
when :go
|
|
40
40
|
FileSelector::Go.predefined(included:, excluded:)
|
|
41
|
+
when :kotlin
|
|
42
|
+
FileSelector::Kotlin.predefined(included:, excluded:)
|
|
41
43
|
end
|
|
42
44
|
end
|
|
43
45
|
|
|
@@ -53,6 +55,8 @@ module ChurnVsComplexity
|
|
|
53
55
|
Complexity::PythonCalculator
|
|
54
56
|
when :go
|
|
55
57
|
Complexity::GoCalculator
|
|
58
|
+
when :kotlin
|
|
59
|
+
Complexity::KotlinCalculator
|
|
56
60
|
end
|
|
57
61
|
end
|
|
58
62
|
end
|
|
@@ -14,6 +14,8 @@ module ChurnVsComplexity
|
|
|
14
14
|
['.py']
|
|
15
15
|
when :go
|
|
16
16
|
['.go']
|
|
17
|
+
when :kotlin
|
|
18
|
+
['.kt', '.kts']
|
|
17
19
|
else
|
|
18
20
|
raise Error, "Unsupported language: #{language}"
|
|
19
21
|
end
|
|
@@ -130,5 +132,15 @@ module ChurnVsComplexity
|
|
|
130
132
|
Predefined.new(included:, extensions: FileSelector.extensions(:go), excluded:)
|
|
131
133
|
end
|
|
132
134
|
end
|
|
135
|
+
|
|
136
|
+
module Kotlin
|
|
137
|
+
def self.excluding(excluded)
|
|
138
|
+
Excluding.new(FileSelector.extensions(:kotlin), excluded)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def self.predefined(included:, excluded:)
|
|
142
|
+
Predefined.new(included:, extensions: FileSelector.extensions(:kotlin), excluded:)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
133
145
|
end
|
|
134
146
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module ChurnVsComplexity
|
|
4
4
|
module LanguageValidator
|
|
5
|
-
SUPPORTED = %i[java ruby javascript python go].freeze
|
|
5
|
+
SUPPORTED = %i[java ruby javascript python go kotlin].freeze
|
|
6
6
|
|
|
7
7
|
def self.validate!(language)
|
|
8
8
|
raise ValidationError, "Unsupported language: #{language}" unless SUPPORTED.include?(language)
|
|
@@ -75,6 +75,14 @@ module ChurnVsComplexity
|
|
|
75
75
|
serializer:,
|
|
76
76
|
since: @since || @relative_period,
|
|
77
77
|
)
|
|
78
|
+
when :kotlin
|
|
79
|
+
Engine.concurrent(
|
|
80
|
+
complexity: Complexity::KotlinCalculator,
|
|
81
|
+
churn:,
|
|
82
|
+
file_selector: FileSelector::Kotlin.excluding(@excluded),
|
|
83
|
+
serializer:,
|
|
84
|
+
since: @since || @relative_period,
|
|
85
|
+
)
|
|
78
86
|
end
|
|
79
87
|
end
|
|
80
88
|
|
|
@@ -14,6 +14,7 @@ module ChurnVsComplexity
|
|
|
14
14
|
# Python Radon Cyclomatic complexity 1 ~44 5-50
|
|
15
15
|
# Java PMD Cyclomatic complexity 1 ~39 1-40
|
|
16
16
|
# Go gocognit Cognitive complexity 0 ~87 0-50
|
|
17
|
+
# Kotlin lizard Cyclomatic complexity 1 ~40 1-40
|
|
17
18
|
#
|
|
18
19
|
# The DEFAULT_LOW and DEFAULT_HIGH thresholds below are rough midpoints
|
|
19
20
|
# suitable for Java/Python/JS. They are too aggressive for Ruby (Flog
|
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: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik T. Madsen
|
|
@@ -39,8 +39,8 @@ dependencies:
|
|
|
39
39
|
version: '2.1'
|
|
40
40
|
description: Correlates file churn (how often files change) with complexity scores
|
|
41
41
|
to identify refactoring hotspots. Supports Ruby, JavaScript/TypeScript, Java, Python,
|
|
42
|
-
and
|
|
43
|
-
comparison, focus sessions, and timetravel history. Inspired by Michael Feathers'
|
|
42
|
+
Go, and Kotlin. Modes include hotspots ranking, triage assessment, CI quality gate,
|
|
43
|
+
diff comparison, focus sessions, and timetravel history. Inspired by Michael Feathers'
|
|
44
44
|
article "Getting Empirical about Refactoring".
|
|
45
45
|
email:
|
|
46
46
|
- beatmadsen@gmail.com
|
|
@@ -69,6 +69,7 @@ files:
|
|
|
69
69
|
- lib/churn_vs_complexity/complexity/eslint_calculator.rb
|
|
70
70
|
- lib/churn_vs_complexity/complexity/flog_calculator.rb
|
|
71
71
|
- lib/churn_vs_complexity/complexity/go_calculator.rb
|
|
72
|
+
- lib/churn_vs_complexity/complexity/kotlin_calculator.rb
|
|
72
73
|
- lib/churn_vs_complexity/complexity/pmd.rb
|
|
73
74
|
- lib/churn_vs_complexity/complexity/pmd/files_calculator.rb
|
|
74
75
|
- lib/churn_vs_complexity/complexity/pmd/folder_calculator.rb
|
|
@@ -145,6 +146,8 @@ files:
|
|
|
145
146
|
- tmp/test-support/javascript/moderate.js
|
|
146
147
|
- tmp/test-support/javascript/simple.js
|
|
147
148
|
- tmp/test-support/javascript/typescript-example.ts
|
|
149
|
+
- tmp/test-support/kotlin/Main.kt
|
|
150
|
+
- tmp/test-support/kotlin/Utils.kt
|
|
148
151
|
- tmp/test-support/python/example.py
|
|
149
152
|
- tmp/test-support/python/utils.py
|
|
150
153
|
- tmp/test-support/txt/abc.txt
|
|
@@ -179,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
179
182
|
- !ruby/object:Gem::Version
|
|
180
183
|
version: '0'
|
|
181
184
|
requirements: []
|
|
182
|
-
rubygems_version:
|
|
185
|
+
rubygems_version: 4.0.6
|
|
183
186
|
specification_version: 4
|
|
184
187
|
summary: Analyse churn vs complexity to find refactoring hotspots, gate CI quality,
|
|
185
188
|
triage risky files, and track codebase health over time.
|