hexx-suit 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +71 -0
  3. data/.yardopts +3 -0
  4. data/Guardfile +29 -0
  5. data/LICENSE +21 -0
  6. data/README.md +164 -0
  7. data/Rakefile +18 -0
  8. data/bin/hexx-suit +14 -0
  9. data/config/initializers/focus.rb +5 -0
  10. data/config/initializers/garbage_collection.rb +11 -0
  11. data/config/initializers/i18n.rb +3 -0
  12. data/config/initializers/metric_fu.rb +0 -0
  13. data/config/initializers/random_order.rb +4 -0
  14. data/config/initializers/rspec.rb +11 -0
  15. data/lib/hexx-suit.rb +16 -0
  16. data/lib/hexx/suit.rb +101 -0
  17. data/lib/hexx/suit/install.rb +85 -0
  18. data/lib/hexx/suit/install/Guardfile +6 -0
  19. data/lib/hexx/suit/install/Rakefile +17 -0
  20. data/lib/hexx/suit/install/_metrics +5 -0
  21. data/lib/hexx/suit/install/_rspec +2 -0
  22. data/lib/hexx/suit/install/_rubocop.yml +74 -0
  23. data/lib/hexx/suit/install/_yardopts +2 -0
  24. data/lib/hexx/suit/install/metrics/STYLEGUIDE +230 -0
  25. data/lib/hexx/suit/install/metrics/cane.yml +5 -0
  26. data/lib/hexx/suit/install/metrics/churn.yml +6 -0
  27. data/lib/hexx/suit/install/metrics/flay.yml +2 -0
  28. data/lib/hexx/suit/install/metrics/metric_fu.yml +15 -0
  29. data/lib/hexx/suit/install/metrics/pippi.yml +3 -0
  30. data/lib/hexx/suit/install/metrics/reek.yml +1 -0
  31. data/lib/hexx/suit/install/metrics/roodi.yml +24 -0
  32. data/lib/hexx/suit/install/metrics/rubocop.yml +79 -0
  33. data/lib/hexx/suit/install/metrics/saikuro.yml +3 -0
  34. data/lib/hexx/suit/install/metrics/simplecov.yml +8 -0
  35. data/lib/hexx/suit/install/metrics/yardstick.yml +37 -0
  36. data/lib/hexx/suit/metrics/base.rb +96 -0
  37. data/lib/hexx/suit/metrics/metric_fu.rb +165 -0
  38. data/lib/hexx/suit/metrics/metric_fu/base.rb +59 -0
  39. data/lib/hexx/suit/metrics/metric_fu/cane.rb +24 -0
  40. data/lib/hexx/suit/metrics/metric_fu/churn.rb +24 -0
  41. data/lib/hexx/suit/metrics/metric_fu/flay.rb +24 -0
  42. data/lib/hexx/suit/metrics/metric_fu/reek.rb +32 -0
  43. data/lib/hexx/suit/metrics/metric_fu/roodi.rb +32 -0
  44. data/lib/hexx/suit/metrics/metric_fu/saikuro.rb +24 -0
  45. data/lib/hexx/suit/metrics/pippi.rb +89 -0
  46. data/lib/hexx/suit/metrics/rubocop.rb +39 -0
  47. data/lib/hexx/suit/metrics/simplecov.rb +119 -0
  48. data/lib/hexx/suit/metrics/yardstick.rb +91 -0
  49. data/lib/hexx/suit/utils/system.rb +66 -0
  50. data/lib/hexx/suit/version.rb +7 -0
  51. data/lib/tasks/check.rake +32 -0
  52. data/lib/tasks/check/coverage.rake +27 -0
  53. data/lib/tasks/check/fu.rake +27 -0
  54. data/lib/tasks/check/inch.rake +11 -0
  55. data/lib/tasks/check/pippi.rake +31 -0
  56. data/lib/tasks/check/rubocop.rake +39 -0
  57. data/lib/tasks/check/yardstick.rake +27 -0
  58. data/lib/tasks/debug.rake +6 -0
  59. data/lib/tasks/test.rake +6 -0
  60. data/spec/spec_helper.rb +10 -0
  61. data/spec/support/config/sandbox.rb +16 -0
  62. data/spec/support/config/tasks.rb +32 -0
  63. data/spec/support/sandbox/helpers.rb +62 -0
  64. data/spec/support/sandbox/matchers.rb +21 -0
  65. data/spec/tests/bin/install_spec.rb +29 -0
  66. data/spec/tests/lib/install_spec.rb +34 -0
  67. data/spec/tests/lib/metrics/metric_fu/cane_spec.rb +32 -0
  68. data/spec/tests/lib/metrics/metric_fu/churn_spec.rb +31 -0
  69. data/spec/tests/lib/metrics/metric_fu/flay_spec.rb +27 -0
  70. data/spec/tests/lib/metrics/metric_fu/reek_spec.rb +22 -0
  71. data/spec/tests/lib/metrics/metric_fu/roodi_spec.rb +22 -0
  72. data/spec/tests/lib/metrics/metric_fu/saikuro_spec.rb +30 -0
  73. data/spec/tests/lib/metrics/metric_fu_spec.rb +181 -0
  74. data/spec/tests/lib/metrics/pippi_spec.rb +102 -0
  75. data/spec/tests/lib/metrics/rubocop_spec.rb +58 -0
  76. data/spec/tests/lib/metrics/simplecov_spec.rb +102 -0
  77. data/spec/tests/lib/metrics/yardstick_spec.rb +110 -0
  78. data/spec/tests/lib/utils/system_spec.rb +85 -0
  79. data/spec/tests/suit_spec.rb +96 -0
  80. data/spec/tests/tasks/check/coverage/display_spec.rb +49 -0
  81. data/spec/tests/tasks/check/coverage/run_spec.rb +25 -0
  82. data/spec/tests/tasks/check/coverage_spec.rb +26 -0
  83. data/spec/tests/tasks/check/display_spec.rb +50 -0
  84. data/spec/tests/tasks/check/fu/display_spec.rb +42 -0
  85. data/spec/tests/tasks/check/fu/run_spec.rb +42 -0
  86. data/spec/tests/tasks/check/fu_spec.rb +18 -0
  87. data/spec/tests/tasks/check/inch_spec.rb +19 -0
  88. data/spec/tests/tasks/check/pippi/display_spec.rb +47 -0
  89. data/spec/tests/tasks/check/pippi/run_spec.rb +25 -0
  90. data/spec/tests/tasks/check/pippi_spec.rb +26 -0
  91. data/spec/tests/tasks/check/rubocop/display_spec.rb +61 -0
  92. data/spec/tests/tasks/check/rubocop/run_spec.rb +78 -0
  93. data/spec/tests/tasks/check/rubocop_spec.rb +26 -0
  94. data/spec/tests/tasks/check/run_spec.rb +44 -0
  95. data/spec/tests/tasks/check/yardstick/display_spec.rb +51 -0
  96. data/spec/tests/tasks/check/yardstick/run_spec.rb +20 -0
  97. data/spec/tests/tasks/check/yardstick_spec.rb +26 -0
  98. data/spec/tests/tasks/check_spec.rb +56 -0
  99. data/spec/tests/tasks/debug_spec.rb +21 -0
  100. data/spec/tests/tasks/test_spec.rb +21 -0
  101. metadata +414 -0
@@ -0,0 +1,15 @@
1
+ ---
2
+ folders: # The list of folders to be used by any metric.
3
+ - lib
4
+ - app
5
+ metrics: # The list of allowed metrics. The other metrics are disabled.
6
+ - cane
7
+ - churn
8
+ - flay
9
+ - flog
10
+ - reek
11
+ - roodi
12
+ - saikuro
13
+ format: html
14
+ output: tmp/metric_fu
15
+ verbose: false
@@ -0,0 +1,3 @@
1
+ ---
2
+ checkset: basic
3
+ output: "tmp/pippi/output.log"
@@ -0,0 +1,24 @@
1
+ ---
2
+ AssignmentInConditionalCheck:
3
+ CaseMissingElseCheck:
4
+ ClassLineCountCheck:
5
+ line_count: 300
6
+ ClassNameCheck:
7
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
8
+ ClassVariableCheck:
9
+ CyclomaticComplexityBlockCheck:
10
+ complexity: 4
11
+ CyclomaticComplexityMethodCheck:
12
+ complexity: 8
13
+ EmptyRescueBodyCheck:
14
+ ForLoopCheck:
15
+ MethodLineCountCheck:
16
+ line_count: 20
17
+ MethodNameCheck:
18
+ pattern: !ruby/regexp /^[\||\^|\&|\!]$|^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
19
+ ModuleLineCountCheck:
20
+ line_count: 300
21
+ ModuleNameCheck:
22
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
23
+ ParameterNumberCheck:
24
+ parameter_count: 5
@@ -0,0 +1,79 @@
1
+ ---
2
+ # settings added by the 'hexx-suit' module
3
+ # output: "tmp/rubocop"
4
+ # format: "html"
5
+
6
+ AllCops:
7
+ Exclude:
8
+ - '**/db/schema.rb'
9
+
10
+ Lint/HandleExceptions:
11
+ Exclude:
12
+ - 'spec/**/*'
13
+
14
+ Lint/RescueException:
15
+ Exclude:
16
+ - 'spec/**/*'
17
+
18
+ Metrics/ClassLength:
19
+ Exclude:
20
+ - 'lib/**/generator*'
21
+
22
+ Style/AccessorMethodName:
23
+ Exclude:
24
+ - 'spec/**/*'
25
+
26
+ Style/AsciiComments:
27
+ Enabled: false
28
+
29
+ Style/ClassAndModuleChildren:
30
+ Exclude:
31
+ - 'spec/**/*'
32
+
33
+ Style/Documentation:
34
+ Exclude:
35
+ - 'lib/**/version.rb'
36
+ - 'spec/**/*'
37
+
38
+ Style/EmptyLinesAroundBlockBody:
39
+ Enabled: false
40
+
41
+ Style/EmptyLinesAroundClassBody:
42
+ Enabled: false
43
+
44
+ Style/EmptyLinesAroundMethodBody:
45
+ Enabled: false
46
+
47
+ Style/EmptyLinesAroundModuleBody:
48
+ Enabled: false
49
+
50
+ Style/EmptyLineBetweenDefs:
51
+ Enabled: false
52
+
53
+ Style/FileName:
54
+ Enabled: false
55
+
56
+ Style/RaiseArgs:
57
+ EnforcedStyle: compact
58
+
59
+ Style/SingleLineMethods:
60
+ Exclude:
61
+ - 'spec/**/*'
62
+
63
+ Style/SingleSpaceBeforeFirstArg:
64
+ Enabled: false
65
+
66
+ Style/SpecialGlobalVars:
67
+ Exclude:
68
+ - 'Gemfile'
69
+ - '*.gemspec'
70
+
71
+ Style/StringLiterals:
72
+ EnforcedStyle: double_quotes
73
+
74
+ Stype/StringLiteralsInInterpolation:
75
+ EnforcedStyle: double_quotes
76
+
77
+ Style/TrivialAccessors:
78
+ Exclude:
79
+ - 'spec/**/*'
@@ -0,0 +1,3 @@
1
+ ---
2
+ warn_cyclo: 4
3
+ error_cyclo: 6
@@ -0,0 +1,8 @@
1
+ ---
2
+ output: tmp/coverage
3
+ filters: # The list of paths to be excluded from coverage checkup
4
+ - "spec/"
5
+ - "config/"
6
+ groups: # The list of groups to be shown in the coverage report
7
+ Libraries: "lib/"
8
+ Application: "app/"
@@ -0,0 +1,37 @@
1
+ ---
2
+ # Settings added by the 'hexx-suit' gem
3
+ output: "tmp/yardstick/output.log"
4
+ path: "lib/**/*.rb"
5
+ rules:
6
+ ApiTag::Presence:
7
+ enabled: true
8
+ exclude: []
9
+ ApiTag::Inclusion:
10
+ enabled: true
11
+ exclude: []
12
+ ApiTag::ProtectedMethod:
13
+ enabled: true
14
+ exclude: []
15
+ ApiTag::PrivateMethod:
16
+ enabled: false
17
+ exclude: []
18
+ ExampleTag:
19
+ enabled: true
20
+ exclude: []
21
+ ReturnTag:
22
+ enabled: true
23
+ exclude: []
24
+ Summary::Presence:
25
+ enabled: true
26
+ exclude: []
27
+ Summary::Length:
28
+ enabled: true
29
+ exclude: []
30
+ Summary::Delimiter:
31
+ enabled: true
32
+ exclude: []
33
+ Summary::SingleLine:
34
+ enabled: true
35
+ exclude: []
36
+ threshold: 100
37
+ verbose: false
@@ -0,0 +1,96 @@
1
+ require "yaml"
2
+
3
+ module Hexx
4
+ module Suit
5
+
6
+ # Contains metric configurators
7
+ #
8
+ # Any configurator loads metric settings from a corresponding yaml,
9
+ # sets necessary environments via {.load} method,
10
+ # and then runs the metric via {.run} method.
11
+ #
12
+ # Configurators loads their own dependencies in a corresponding constructor.
13
+ module Metrics
14
+
15
+ # Base class for metrics configurators
16
+ #
17
+ # @api private
18
+ class Base
19
+
20
+ # The utility class for sending commands to the system
21
+ SYSTEM = Utils::System
22
+
23
+ # Loads metric settings and configures the current metric
24
+ #
25
+ # @return (see #load)
26
+ def self.load
27
+ send(:new).load
28
+ end
29
+
30
+ # Configures and runs the current metric
31
+ #
32
+ # @return (see #run)
33
+ def self.run
34
+ load.run
35
+ end
36
+
37
+ # Loads the configuration file and configures the metric
38
+ #
39
+ # @abstract
40
+ #
41
+ # @return [Hexx::Suit::Metrics]
42
+ # the configured metric object
43
+ #
44
+ # @api private
45
+ def load
46
+ self
47
+ end
48
+
49
+ # Runs the metric
50
+ #
51
+ # @abstract
52
+ #
53
+ # @return [undefined]
54
+ #
55
+ # @api private
56
+ def run
57
+ end
58
+
59
+ # @note
60
+ # The class has a private constructor.
61
+ # Use methods {.load} or {.run}.
62
+ private_class_method :new
63
+
64
+ private
65
+
66
+ # Extracts a hash of settings from the current file
67
+ #
68
+ # @return [Hash]
69
+ #
70
+ # @api private
71
+ def settings
72
+ @settings ||= file ? ::YAML.load_file(file) : {}
73
+ end
74
+
75
+ # Returns the name of the settings file
76
+ #
77
+ # @return [String]
78
+ # when the file is present in the config/metrics folder
79
+ # @return [nil]
80
+ # when the file is absent in the config/metrics folder
81
+ #
82
+ # @api private
83
+ def file
84
+ @file ||= Dir["config/metrics/#{ name }.yml"].first
85
+ end
86
+
87
+ # The name of the current metric
88
+ #
89
+ # @abstract
90
+ #
91
+ # @return [Symbol]
92
+ attr_reader :name
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,165 @@
1
+ # encoding: utf-8
2
+
3
+ module Hexx
4
+ module Suit
5
+ module Metrics
6
+
7
+ # Configurator for the metric_fu and all its subpackages
8
+ class MetricFu < Base
9
+
10
+ # Loads the metric_fu gem dependency
11
+ #
12
+ # @return [Hexx::Suit::Metrics::MetricFu]
13
+ def self.new
14
+ require "metric_fu"
15
+ super
16
+ end
17
+
18
+ # Loads common settings and configures metrics
19
+ #
20
+ # @return [self]
21
+ def load
22
+ set_environment
23
+ configure_metric_fu
24
+ configure_packages
25
+
26
+ self
27
+ end
28
+
29
+ private
30
+
31
+ # metric_fu definitions
32
+
33
+ def packages
34
+ %w(
35
+ cane churn flay flog reek roodi saikuro
36
+ hotspots rails_best_practices rcov stats
37
+ )
38
+ end
39
+
40
+ def name
41
+ :metric_fu
42
+ end
43
+
44
+ def default_options
45
+ {
46
+ "folders" => %(lib app),
47
+ "format" => "html",
48
+ "metrics" => %(cane churn flay flog reek roodi saikuro),
49
+ "output" => "tmp/metric_fu",
50
+ "verbose" => false
51
+ }
52
+ end
53
+
54
+ def configuration
55
+ ::MetricFu::Configuration
56
+ end
57
+
58
+ # operations
59
+
60
+ def set_environment
61
+ ENV["METRIC_FU_OUTPUT"] = options["output"]
62
+ end
63
+
64
+ def configure_metric_fu
65
+ configuration.run do |config|
66
+ config.configure_formatter options["format"].to_sym
67
+ config.verbose = options["verbose"]
68
+ end
69
+ end
70
+
71
+ def configure_packages
72
+ packages.map { |item| "configure_#{ item }" }.each(&method(:send))
73
+ end
74
+
75
+ def configure_cane
76
+ configure(:cane) do |metric|
77
+ metric.dirs_to_cane = folders
78
+ Cane.load # loads settings from cane.yml
79
+ end
80
+ end
81
+
82
+ def configure_churn
83
+ configure(:churn) do |metric|
84
+ metric.configured_run_options[:dirs_to_churn] = folders
85
+ Churn.load # loads settings from churn.yml
86
+ end
87
+ end
88
+
89
+ def configure_flog
90
+ configure(:flog) do |metric|
91
+ metric.dirs_to_flog = folders
92
+ # no additional settings exist
93
+ end
94
+ end
95
+
96
+ def configure_flay
97
+ configure(:flay) do |metric|
98
+ metric.dirs_to_flay = folders
99
+ Flay.load # loads settings from flay.yml
100
+ end
101
+ end
102
+
103
+ def configure_hotspots
104
+ configure(:hotspots)
105
+ end
106
+
107
+ def configure_rails_best_practices
108
+ configure(:rails_best_practices)
109
+ end
110
+
111
+ def configure_rcov
112
+ configure(:reek) do |metric|
113
+ metric.configured_run_options[:dirs_to_rcov] = folders
114
+ end
115
+ end
116
+
117
+ def configure_reek
118
+ configure(:reek) do |metric|
119
+ metric.dirs_to_reek = folders
120
+ Reek.load # loads settings from reek.yml
121
+ end
122
+ end
123
+
124
+ def configure_roodi
125
+ configure(:roodi) do |metric|
126
+ metric.dirs_to_roodi = folders
127
+ Roodi.load # loads settings from roodi.yml
128
+ end
129
+ end
130
+
131
+ def configure_saikuro
132
+ configure(:saikuro) do |metric|
133
+ metric.input_directory = folders
134
+ Saikuro.load # loads settings from saikuro.yml
135
+ end
136
+ end
137
+
138
+ def configure_stats
139
+ configure(:stats)
140
+ end
141
+
142
+ # helpers
143
+
144
+ def configure(name)
145
+ configuration.configure_metric(name) do |metric|
146
+ metric.enabled = metrics.include? name.to_s
147
+ yield(metric) if block_given?
148
+ end
149
+ end
150
+
151
+ def options
152
+ @options ||= default_options.merge settings.to_h
153
+ end
154
+
155
+ def metrics
156
+ @metrics ||= options["metrics"]
157
+ end
158
+
159
+ def folders
160
+ @folders ||= options["folders"]
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ module Hexx
4
+ module Suit
5
+ module Metrics
6
+ class MetricFu < Base
7
+
8
+ # Base class for metrics configured via metric_fu
9
+ class Base < Metrics::Base
10
+
11
+ # Constructs the object and loads 'metric_fu' dependency
12
+ #
13
+ # @return [Hexx::Suit::Metrics::MetricFu]
14
+ #
15
+ # @api private
16
+ def self.new
17
+ require "metric_fu"
18
+ super
19
+ end
20
+
21
+ # @!scope class
22
+ # Initializes and configures the metric from a corresponding yml
23
+ #
24
+ # @return [self]
25
+ def load
26
+ configure { |metric| options.each { |option| add(metric, option) } }
27
+
28
+ self
29
+ end
30
+
31
+ private
32
+
33
+ # current metric definitions
34
+
35
+ def name
36
+ :metric_fu
37
+ end
38
+
39
+ def options
40
+ %w()
41
+ end
42
+
43
+ # helpers
44
+
45
+ def add(metric, option)
46
+ value = settings[option]
47
+ metric.send option, value unless value.nil?
48
+ end
49
+
50
+ def configure
51
+ ::MetricFu::Configuration.configure_metric(name) do |metric|
52
+ yield(metric)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end