Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit fdc5757

Browse files
committed
Merge pull request #109 from codeclimate/devon/add-debug-logging
Add debug logging option
2 parents 72c3a8b + 8883adc commit fdc5757

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

‎lib/cc/engine/analyzers/engine_config.rb‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ def initialize(hash)
66
@config = normalize(hash)
77
end
88

9+
def debug?
10+
config.fetch("config", {}).fetch("debug", false)
11+
end
12+
913
def include_paths
1014
config.fetch("include_paths", ["./"])
1115
end

‎lib/cc/engine/analyzers/reporter.rb‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ def initialize(engine_config, language_strategy, io)
1616
end
1717

1818
def run
19+
debug("Processing #{language_strategy.files.count} files concurrency=#{engine_config.concurrency}")
20+
1921
process_files
2022
report
23+
24+
debug("Reported #{reports.size} violations...")
2125
end
2226

2327
def process_files
@@ -26,19 +30,29 @@ def process_files
2630
concurrency: engine_config.concurrency
2731
)
2832

33+
processed_files_count = Concurrent::AtomicFixnum.new
34+
2935
pool.run do |file|
36+
debug("Processing file: #{file}")
37+
3038
sexp = language_strategy.run(file)
3139
process_sexp(sexp)
40+
41+
processed_files_count.increment
3242
end
3343

3444
pool.join
45+
46+
debug("Processed #{processed_files_count.value} files")
3547
end
3648

3749
def report
3850
flay.report(StringIO.new).each do |issue|
3951
violations = new_violations(issue)
4052

4153
violations.each do |violation|
54+
debug("Violation name=#{violation.report_name} mass=#{violation.mass}")
55+
4256
unless reports.include?(violation.report_name)
4357
reports.add(violation.report_name)
4458
io.puts "#{violation.format.to_json}0円"
@@ -80,6 +94,10 @@ def flay_options
8094
only: nil
8195
}
8296
end
97+
98+
def debug(message)
99+
$stderr.puts(message) if engine_config.debug?
100+
end
83101
end
84102
end
85103
end

‎spec/support/helpers/analyzer_spec_helpers.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def run_engine(config = nil)
1111
io = StringIO.new
1212

1313
engine = described_class.new(engine_config: config)
14-
reporter = ::CC::Engine::Analyzers::Reporter.new(double(concurrency: 2), engine, io)
14+
reporter = ::CC::Engine::Analyzers::Reporter.new(config, engine, io)
1515

1616
reporter.run
1717

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /