debt_ceiling 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/bin/debt_ceiling +0 -21
- data/lib/debt_ceiling/accounting.rb +37 -0
- data/lib/debt_ceiling/version.rb +1 -1
- data/lib/debt_ceiling.rb +11 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b3cdc1008d893ea9057c63dd4834d2b801dfaff
|
4
|
+
data.tar.gz: 8df6b9d644c3efc86e93b84426ef96bbd10cd105
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cb2015140741a74a2a3a70f499cc26cd236b5da6d47280f4e8e0471b61761b458d587acc1ed7748dedbfba31e5e8c7b231655b1d7f2ef1cc56738aa611a4c5c
|
7
|
+
data.tar.gz: 0748963438e02fd19db6646ab1ea71e08bf6d956931b5d0be120c31f150214c64711b5acc8ada8ff44324138b01090f05c2672041da078416c3124ddae24d0e2
|
data/README.md
CHANGED
@@ -2,18 +2,21 @@
|
|
2
2
|
|
3
3
|
#DebtCeiling
|
4
4
|
|
5
|
+
### Work in progress, feedback and PR's appreciated
|
5
6
|
|
6
|
-
|
7
|
+
Main goal is to enforce a technical debt ceiling and tech debt reduction deadlines for your Ruby project programmatically via static analysis as part of your application's test suite. Eventually perhaps will aid in visualizing tech debt as a graph or graphs (breakind down debt into various categories and sources).
|
7
8
|
|
8
9
|
Current features include:
|
9
10
|
* configuring points per [RubyCritic](https://github.com/whitesmith/rubycritic) grade per file line
|
10
|
-
* Whitelisting/blacklisting files by filename
|
11
|
+
* Whitelisting/blacklisting files by matching path/filename
|
11
12
|
* Modifying or replacing default calculation on a per file basis
|
12
13
|
* Reporting the single greatest source of debt based on your definitions
|
13
14
|
* Reporting total debt for the git repo based on your definitions
|
14
15
|
* Running the binary from a test suite to fail if debt ceiling is exceeded
|
15
16
|
* Running the binary from a test suite to fail if debt deadline is missed
|
16
17
|
|
18
|
+
To integrate in a test suite, use `set_debt_ceiling` and/or `debt_reduction_target_and_date` in your configuration and call `DebtCeiling.calculate(root_dir)` from your test helper as an additional test. It will exit with a non-zero failure if you exceed your ceiling or miss your target, failing the test suite.
|
19
|
+
|
17
20
|
These features are largely are demonstrated/discussed in [examples/.debt_ceiling](https://github.com/bglusman/debt_ceiling/blob/master/examples/.debt_ceiling.example) which demonstrates configuring debt ceiling
|
18
21
|
|
19
22
|
Additional customization is supported via two method hooks in the debt class, which debt_ceiling will load from a provided extension_file_path in the main config file, which should look like the [example file](https://github.com/bglusman/debt_ceiling/blob/master/examples/debt.rb.example)
|
@@ -73,4 +76,4 @@ include one of the JS complexity/debt analysis libraries below, or another if an
|
|
73
76
|
|
74
77
|
* https://github.com/dpnishant/jsprime
|
75
78
|
|
76
|
-
* https://github.com/mozilla/doctorjs
|
79
|
+
* https://github.com/mozilla/doctorjs
|
data/bin/debt_ceiling
CHANGED
@@ -1,24 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
2
|
require_relative "../lib/debt_ceiling"
|
4
|
-
if File.exists?(Dir.pwd + '/.debt_ceiling')
|
5
|
-
File.open(Dir.pwd + "/.debt_ceiling") {|f| DebtCeiling.module_eval(f.read)}
|
6
|
-
elsif File.exists?(Dir.home + '/.debt_ceiling')
|
7
|
-
File.open(Dir.home + '/.debt_ceiling') {|f| DebtCeiling.module_eval(f.read)}
|
8
|
-
else
|
9
|
-
puts "
|
10
|
-
***NOTICE:***
|
11
|
-
Using example .debt_ceiling file, which can be copied and customized from
|
12
|
-
#{File.dirname(File.dirname(`gem which debt_ceiling`.chop)) + '/examples/.debt_ceiling.example'}\n
|
13
|
-
place .debt_ceiling file in project directory and/or home directories, debt_ceiling looks
|
14
|
-
at pwd first for ./debt_ceiling and then at ~/.debt_ceiling and defaults to example
|
15
|
-
if neither is found\n\n"
|
16
|
-
|
17
|
-
File.open(File.dirname(File.dirname(`gem which debt_ceiling`.chop)) +
|
18
|
-
'/examples/.debt_ceiling.example') {|f| DebtCeiling.module_eval(f.read)}
|
19
|
-
end
|
20
|
-
|
21
|
-
extension_path = DebtCeiling.current_extension_file_path
|
22
|
-
load extension_path if File.exists?(extension_path)
|
23
|
-
|
24
3
|
DebtCeiling.calculate(ARGV[0] ? ARGV[0] : ".")
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubycritic'
|
2
|
+
require 'ostruct'
|
3
|
+
module DebtCeiling
|
4
|
+
class Accounting
|
5
|
+
DebtCeilingExceeded = Class.new(StandardError)
|
6
|
+
TargetDeadlineMissed = Class.new(StandardError)
|
7
|
+
class << self
|
8
|
+
def calculate(path)
|
9
|
+
#temporarily use Rubycritic internals until they provide an API
|
10
|
+
require "rubycritic/modules_initializer"
|
11
|
+
require "rubycritic/analysers/complexity"
|
12
|
+
require "rubycritic/analysers/smells/flay"
|
13
|
+
|
14
|
+
analysed_modules = Rubycritic::ModulesInitializer.init([path])
|
15
|
+
[Rubycritic::Analyser::Complexity, Rubycritic::Analyser::FlaySmells].each do |analyser|
|
16
|
+
analyser.new(analysed_modules).run
|
17
|
+
end
|
18
|
+
debts = construct_debts(analysed_modules)
|
19
|
+
max_debt = debts.max_by(&:to_i)
|
20
|
+
total_debt = debts.map(&:to_i).reduce(&:+)
|
21
|
+
puts "Current total tech debt: #{total_debt}"
|
22
|
+
puts "Largest source of debt is: #{max_debt.file_attributes.analysed_module.name} at #{max_debt.to_i}"
|
23
|
+
total_debt
|
24
|
+
end
|
25
|
+
|
26
|
+
def construct_debts(modules)
|
27
|
+
modules.map do |mod|
|
28
|
+
file_attributes = OpenStruct.new
|
29
|
+
file_attributes.linecount = `wc -l #{mod.path}`.match(/\d+/)[0].to_i
|
30
|
+
file_attributes.path = mod.path
|
31
|
+
file_attributes.analysed_module = mod
|
32
|
+
debt_rule = Debt.new(file_attributes)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/debt_ceiling/version.rb
CHANGED
data/lib/debt_ceiling.rb
CHANGED
@@ -6,6 +6,17 @@ module DebtCeiling
|
|
6
6
|
extend self
|
7
7
|
|
8
8
|
def calculate(dir=".")
|
9
|
+
if File.exists?(Dir.pwd + '/.debt_ceiling')
|
10
|
+
File.open(Dir.pwd + "/.debt_ceiling") {|f| DebtCeiling.module_eval(f.read)}
|
11
|
+
elsif File.exists?(Dir.home + '/.debt_ceiling')
|
12
|
+
File.open(Dir.home + '/.debt_ceiling') {|f| DebtCeiling.module_eval(f.read)}
|
13
|
+
else
|
14
|
+
puts "No .debt_ceiling configuration file detected in #{Dir.pwd} or ~/, using defaults"
|
15
|
+
end
|
16
|
+
|
17
|
+
extension_path = DebtCeiling.current_extension_file_path
|
18
|
+
load extension_path if extension_path && File.exists?(extension_path)
|
19
|
+
|
9
20
|
@debt = DebtCeiling::Accounting.calculate(dir)
|
10
21
|
evaluate
|
11
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debt_ceiling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Glusman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubycritic
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- examples/.debt_ceiling.example
|
101
101
|
- examples/debt.rb.example
|
102
102
|
- lib/debt_ceiling.rb
|
103
|
+
- lib/debt_ceiling/accounting.rb
|
103
104
|
- lib/debt_ceiling/debt.rb
|
104
105
|
- lib/debt_ceiling/version.rb
|
105
106
|
- test/debt_ceiling_test.rb
|
@@ -128,3 +129,4 @@ signing_key:
|
|
128
129
|
specification_version: 4
|
129
130
|
summary: DebtCeiling helps you track Tech Debt
|
130
131
|
test_files: []
|
132
|
+
has_rdoc:
|