Class: Bozo::Hooks::FxCop
- Inherits:
-
Object
- Object
- Bozo::Hooks::FxCop
- Defined in:
- lib/bozo/hooks/fxcop.rb
Overview
Specifies a hook for running FxCop.
The default configuration runs against the compiled assemblies produced via msbuild.
Alternatively a specific .fxcop project file can be specified in the configuration.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ FxCop
constructor
A new instance of FxCop.
-
#path(path = nil) ⇒ Object
Specifies the fxcop path.
-
#post_compile ⇒ Object
Runs the post_compile hook.
-
#project(project) ⇒ Object
Specifies an fxcop project file.
-
#type(type) ⇒ Object
Adds a type to analyze.
Constructor Details
#initialize ⇒ FxCop
Returns a new instance of FxCop.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bozo/hooks/fxcop.rb', line 22 def initialize @@defaults = { :types => [], :framework_versions => [:net35, :net40], :project => nil, :path => FxCop.default_path } @config = {} end |
Class Method Details
.default_path ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/bozo/hooks/fxcop.rb', line 12 def self.default_path if ENV['ProgramFiles(x86)'].nil? program_files_path = ENV['ProgramFiles'] else program_files_path = ENV['ProgramFiles(x86)'] end File.join(program_files_path, 'Microsoft Fxcop 10.0', 'fxcopcmd.exe') unless program_files_path.nil? end |
Instance Method Details
#path(path = nil) ⇒ Object
Specifies the fxcop path
45 46 47 48 49 |
# File 'lib/bozo/hooks/fxcop.rb', line 45 def path(path = nil) @config[:path] = path unless path.nil? @config[:path] end |
#post_compile ⇒ Object
Runs the post_compile hook
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bozo/hooks/fxcop.rb', line 52 def post_compile config = config_with_defaults raise no_executable_path_specified if path.nil? raise no_executable_exists unless File.exists?(path) if config[:project].nil? execute_projects config else execute_fxcop_project config end end |
#project(project) ⇒ Object
Specifies an fxcop project file
40 41 42 |
# File 'lib/bozo/hooks/fxcop.rb', line 40 def project(project) @config[:project] = project end |
#type(type) ⇒ Object
Adds a type to analyze
34 35 36 37 |
# File 'lib/bozo/hooks/fxcop.rb', line 34 def type(type) @config[:types] ||= [] @config[:types] << type end |