forked from troessner/reek
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added masked smells to report headers
- Loading branch information
1 parent
db1985a
commit 079dca3
Showing
9 changed files
with
84 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'yaml' | ||
|
||
module Reek | ||
class ConfigFile | ||
|
||
def initialize(file_path) | ||
@file_path = file_path | ||
@hash = YAML.load_file(@file_path) || {} | ||
problem('not a Hash') unless Hash === @hash | ||
end | ||
|
||
# | ||
# Configure the given sniffer using the contents of the config file. | ||
# | ||
def configure(sniffer) | ||
@hash.each { |klass_name, config| | ||
sniffer.configure(find_class(klass_name), config) | ||
} | ||
end | ||
|
||
def find_class(name) | ||
klass = Reek::Smells.const_get(name) | ||
problem("#{name} is not a code smell") unless klass | ||
klass | ||
end | ||
|
||
def problem(reason) | ||
raise "Invalid configuration file \"#{File.basename(@file_path)}\" -- #{reason}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
module Reek | ||
class DetectorStack | ||
|
||
def initialize(default_detector) | ||
@detectors = [default_detector] | ||
end | ||
|
||
def push(config) | ||
det = @detectors[0].copy | ||
det.configure_with(config) | ||
@detectors.each {|smell| smell.be_masked} | ||
@detectors << det | ||
end | ||
|
||
def listen_to(hooks) | ||
@detectors.each { |smell| smell.listen_to(hooks) } | ||
end | ||
|
||
def report_on(report) | ||
@detectors.each { |smell| smell.report_on(report) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters