Skip to content

Commit

Permalink
Add --details flag to control attribution/date
Browse files Browse the repository at this point in the history
Also mixup readme and tweak debt settings.
  • Loading branch information
bglusman committed Jul 6, 2016
1 parent 9f7aa61 commit d056797
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .debt_ceiling.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DebtCeiling.configure do |c|
c.whitelist = %w(bin lib)
c.max_debt_per_module = 150
c.debt_ceiling = 450
c.max_debt_per_module = 100
c.debt_ceiling = 500
end
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
[![Code Climate](https://codeclimate.com/github/bglusman/debt_ceiling/badges/gpa.svg)](https://codeclimate.com/github/bglusman/debt_ceiling)
#DebtCeiling

Main goal is to enforce a technical debt ceiling and tech debt reduction deadlines for your Ruby project programmatically via a configurable combination of static analysis and/or manual assignment/recognition from explicit source code references as part of your application's test suite. Eventually perhaps will aid in visualizing this quantification as a graph or graphs, and breaking down debt into various categories and sources. Currently it highlights the single largest source of debt as a suggestion for reduction, as well out outputting the total quantity, both in test suite integration or by manually running `debt_ceiling` binary.
Main goal is to track and/or enforce a technical debt ceiling and tech debt reduction deadlines for your Ruby project, however you choose to define and quantify technical debt. Uses a configurable combination of static analysis and/or manual assignment/recognition from explicit source code references as part of your application's test suite, or from CLI.

## Compatibility

Travis tests are running on 1.9.3, 2.1.1, 2.2.2, 2.3.0, Rubinius 2.8 and JRuby 1.9 mode.
Travis tests are running on MRI 1.9.3, 2.1.1, 2.2.5, and 2.3.1, JRuby (1.9 mode and JRuby 9120), and Rubinius (3.2.0)

## Current Features

* Compiled todo list, with optional author/date info per todo
* All custom/manual sources of debt are output via `debt_ceiling todo`
* Add a `--details` flag to include author/date info, or set `todo_author_date_info` to true in config to always show.
* Defaults to only showing via explicit todo, but can show during audit output if set `report_todos` to true in config.
* configuring points per [RubyCritic](https://github.com/whitesmith/rubycritic) grade per file
* configuring multipliers for specific static analysis attributes, including complexity, duplication, method count, reek smells
* configuring ideal max lines per file/module, and a per line penalty for each additional line
Expand Down
10 changes: 7 additions & 3 deletions bin/debt_ceiling
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env ruby
require_relative '../lib/debt_ceiling'
def path_arg(position)
ARGV[position] && !ARGV[position].match('--') ? ARGV[position] : '.'
end

if ARGV[0] == 'dig'
DebtCeiling.dig(ARGV[1] ? ARGV[1] : '.')
DebtCeiling.dig(path_arg(1))
elsif ARGV[0] == 'todo'
DebtCeiling.todo(ARGV[1] ? ARGV[1] : '.')
DebtCeiling.todo(path_arg(1))
else
DebtCeiling.audit(ARGV[0] ? ARGV[0] : '.')
DebtCeiling.audit(path_arg(0))
end
6 changes: 6 additions & 0 deletions lib/debt_ceiling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module DebtCeiling
:debt_types,
:archeology_detail,
:report_todos,
:todo_author_date_info,
:memoize_records_in_repo
]
DEFAULT_CALLOUTS = ['TECH DEBT']
Expand All @@ -61,6 +62,7 @@ module DebtCeiling
config.debt_types = [CustomDebt, StaticAnalysisDebt]
config.archeology_detail = :low
config.report_todos = true # when running regular debt test, always shows for debt_ceiling todo
config.todo_author_date_info = details?
config.memoize_records_in_repo = false # set to true to use git notes to save archaeological dig results
}

Expand Down Expand Up @@ -105,4 +107,8 @@ def config_array
CONFIGURATION_OPTIONS.map {|option| public_send(option) }
end

def self.details?
[ARGV[0], ARGV[1], ARGV[2]].any? {|arg| arg.to_s.match '--details'}
end

end
8 changes: 6 additions & 2 deletions lib/debt_ceiling/custom_debt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ def prepare_report
end

def add_line(line, index)
author, date = find_author_date(index)
report_text[index] = [line, author, date]
if DebtCeiling.todo_author_date_info
author, date = find_author_date(index)
report_text[index] = [line, author, date]
else
report_text[index] = line
end
end

def find_author_date(line)
Expand Down

0 comments on commit d056797

Please sign in to comment.