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,34 @@
1
+ # encoding: utf-8
2
+
3
+ describe Hexx::Suit::Install, :sandbox do
4
+
5
+ describe ".start" do
6
+
7
+ before { try_in_sandbox { described_class.start } }
8
+
9
+ it "creates necessary files" do
10
+ %w(
11
+ .rspec
12
+ .yardopts
13
+ Guardfile
14
+ Rakefile
15
+ config/metrics/cane.yml
16
+ config/metrics/churn.yml
17
+ config/metrics/flay.yml
18
+ config/metrics/metric_fu.yml
19
+ config/metrics/pippi.yml
20
+ config/metrics/reek.yml
21
+ config/metrics/roodi.yml
22
+ config/metrics/rubocop.yml
23
+ config/metrics/saikuro.yml
24
+ config/metrics/simplecov.yml
25
+ config/metrics/yardstick.yml
26
+ config/metrics/STYLEGUIDE
27
+ ).each { |file| expect(file).to be_present_in_sandbox }
28
+ end
29
+
30
+ it "adds Hexx::Suit tasks loader to Rakefile" do
31
+ expect(read_in_sandbox "Rakefile").to include "Hexx::Suit.install_tasks"
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "metric_fu"
4
+
5
+ describe Hexx::Suit::Metrics::MetricFu::Cane, :sandbox do
6
+
7
+ let(:config) do
8
+ ::MetricFu::Configuration.configure_metric(:cane) do |metric|
9
+ metric.instance_eval { @configured_run_options || {} }
10
+ end
11
+ end
12
+
13
+ let(:settings) do
14
+ {
15
+ "abc_max" => "10",
16
+ "line_length" => "80",
17
+ "no_doc" => "y",
18
+ "no_readme" => "y"
19
+ }
20
+ end
21
+
22
+ describe ".load" do
23
+
24
+ before { prepare_settings settings, "config/metrics/cane.yml" }
25
+ subject { try_in_sandbox { described_class.load } }
26
+
27
+ it "configures the metric from cane.yml" do
28
+ subject
29
+ settings.each { |key, value| expect(config[key.to_sym]).to eq value }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "metric_fu"
4
+
5
+ describe Hexx::Suit::Metrics::MetricFu::Churn, :sandbox do
6
+
7
+ let(:config) do
8
+ ::MetricFu::Configuration.configure_metric(:churn) do |metric|
9
+ metric.instance_eval { @configured_run_options || {} }
10
+ end
11
+ end
12
+
13
+ let(:settings) do
14
+ {
15
+ "ignore_files" => %w(spec),
16
+ "minimum_churn_count" => "1",
17
+ "start_date" => "6 months ago"
18
+ }
19
+ end
20
+
21
+ describe ".load" do
22
+
23
+ before { prepare_settings settings, "config/metrics/churn.yml" }
24
+ subject { try_in_sandbox { described_class.load } }
25
+
26
+ it "configures the metric from churn.yml" do
27
+ subject
28
+ settings.each { |key, value| expect(config[key.to_sym]).to eq value }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "metric_fu"
4
+
5
+ describe Hexx::Suit::Metrics::MetricFu::Flay, :sandbox do
6
+
7
+ let(:config) do
8
+ ::MetricFu::Configuration.configure_metric(:flay) do |metric|
9
+ metric.instance_eval { @configured_run_options || {} }
10
+ end
11
+ end
12
+
13
+ let(:settings) do
14
+ { "minimum_score" => "10" }
15
+ end
16
+
17
+ describe ".load" do
18
+
19
+ before { prepare_settings settings, "config/metrics/flay.yml" }
20
+ subject { try_in_sandbox { described_class.load } }
21
+
22
+ it "configures the metric from flay.yml" do
23
+ subject
24
+ settings.each { |key, value| expect(config[key.to_sym]).to eq value }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "metric_fu"
4
+
5
+ describe Hexx::Suit::Metrics::MetricFu::Reek, :sandbox do
6
+
7
+ let(:config) do
8
+ ::MetricFu::Configuration.configure_metric(:reek) do |metric|
9
+ metric.instance_eval { @configured_run_options || {} }
10
+ end
11
+ end
12
+
13
+ describe ".load" do
14
+
15
+ subject { try_in_sandbox { described_class.load } }
16
+
17
+ it "configures the metric from reek.yml" do
18
+ subject
19
+ expect(config[:config_file_pattern]).to eq "config/metrics/reek.yml"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "metric_fu"
4
+
5
+ describe Hexx::Suit::Metrics::MetricFu::Roodi, :sandbox do
6
+
7
+ let(:config) do
8
+ ::MetricFu::Configuration.configure_metric(:roodi) do |metric|
9
+ metric.instance_eval { @configured_run_options || {} }
10
+ end
11
+ end
12
+
13
+ describe ".load" do
14
+
15
+ subject { try_in_sandbox { described_class.load } }
16
+
17
+ it "configures the metric from roodi.yml" do
18
+ subject
19
+ expect(config[:roodi_config]).to eq "config/metrics/roodi.yml"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "metric_fu"
4
+
5
+ describe Hexx::Suit::Metrics::MetricFu::Saikuro, :sandbox do
6
+
7
+ let(:config) do
8
+ ::MetricFu::Configuration.configure_metric(:saikuro) do |metric|
9
+ metric.instance_eval { @configured_run_options || {} }
10
+ end
11
+ end
12
+
13
+ let(:settings) do
14
+ {
15
+ "warn_cyclo" => "3",
16
+ "error_cyclo" => "5"
17
+ }
18
+ end
19
+
20
+ describe ".load" do
21
+
22
+ before { prepare_settings settings, "config/metrics/saikuro.yml" }
23
+ subject { try_in_sandbox { described_class.load } }
24
+
25
+ it "configures the metric from saikuro.yml" do
26
+ subject
27
+ settings.each { |key, value| expect(config[key.to_sym]).to eq value }
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,181 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "metric_fu"
4
+
5
+ describe Hexx::Suit::Metrics::MetricFu, :sandbox do
6
+
7
+ shared_context "without metric_fu.yml" do
8
+
9
+ let(:options) do
10
+ {
11
+ "folders" => %(lib app),
12
+ "format" => "html",
13
+ "metrics" => %w(cane churn flay flog reek roodi saikuro),
14
+ "output" => "tmp/metric_fu",
15
+ "verbose" => false
16
+ }
17
+ end
18
+ end
19
+
20
+ shared_context "with metric_fu.yml" do
21
+
22
+ let(:options) do
23
+ {
24
+ "folders" => %(custom),
25
+ "format" => "yaml",
26
+ "metrics" => %w(hotspots stats),
27
+ "output" => "custom",
28
+ "verbose" => true
29
+ }
30
+ end
31
+
32
+ before { prepare_settings options, "config/metrics/metric_fu.yml" }
33
+ end
34
+
35
+ shared_examples "environment setter" do
36
+
37
+ before { ENV["METRIC_FU_OUTPUT"] = nil }
38
+
39
+ it "[sets METRIC_FU_OUTPUT]" do
40
+ expect { subject }
41
+ .to change { ENV["METRIC_FU_OUTPUT"] }
42
+ .to options["output"]
43
+ end
44
+ end
45
+
46
+ shared_examples "verbose setter" do
47
+
48
+ before { subject }
49
+
50
+ it "[sets verbose from options]" do
51
+ ::MetricFu::Configuration.run do |config|
52
+ expect(config.verbose).to eq options["verbose"]
53
+ end
54
+ end
55
+ end
56
+
57
+ shared_examples "metrics selector" do
58
+
59
+ def enabled?(name)
60
+ ::MetricFu::Configuration.configure_metric(name.to_sym) do |metric|
61
+ metric.instance_eval { @enabled }
62
+ end
63
+ end
64
+
65
+ let(:metrics) do
66
+ %w(
67
+ cane churn flay flog hotspots rails_best_practices rcov reek roodi
68
+ saikuro stats
69
+ )
70
+ end
71
+ let(:allowed_metrics) { options["metrics"] }
72
+ let(:disabled_metrics) { metrics - allowed_metrics }
73
+
74
+ before { subject }
75
+
76
+ it "[enables allowed metrics]" do
77
+ allowed_metrics.each { |name| expect(enabled? name).to be_truthy }
78
+ end
79
+
80
+ it "[disables other metrics]" do
81
+ disabled_metrics.each { |name| expect(enabled? name).to be_falsey }
82
+ end
83
+ end
84
+
85
+ shared_examples "folders setter" do
86
+
87
+ def run_options(name)
88
+ ::MetricFu::Configuration.configure_metric(name.to_sym) do |metric|
89
+ metric.instance_eval { @configured_run_options || {} }
90
+ end
91
+ end
92
+
93
+ let(:folders) { options["folders"] }
94
+
95
+ before { subject }
96
+
97
+ it "[sets cane folders]" do
98
+ expect(run_options(:cane)[:dirs_to_cane]).to eq folders
99
+ end
100
+
101
+ it "[sets churn folders]" do
102
+ expect(run_options(:churn)[:dirs_to_churn]).to eq folders
103
+ end
104
+
105
+ it "[sets flay folders]" do
106
+ expect(run_options(:flay)[:dirs_to_flay]).to eq folders
107
+ end
108
+
109
+ it "[sets flog folders]" do
110
+ expect(run_options(:flog)[:dirs_to_flog]).to eq folders
111
+ end
112
+
113
+ it "[sets reek folders]" do
114
+ expect(run_options(:reek)[:dirs_to_reek]).to eq folders
115
+ end
116
+
117
+ it "[sets roodi folders]" do
118
+ expect(run_options(:roodi)[:dirs_to_roodi]).to eq folders
119
+ end
120
+
121
+ it "[sets saikuro folders]" do
122
+ expect(run_options(:saikuro)[:input_directory]).to eq folders
123
+ end
124
+ end
125
+
126
+ shared_examples "metrics loader" do
127
+
128
+ after { subject }
129
+
130
+ it "[loads cane]" do
131
+ expect(described_class::Cane).to receive :load
132
+ end
133
+
134
+ it "[loads churn]" do
135
+ expect(described_class::Churn).to receive :load
136
+ end
137
+
138
+ it "[loads flay]" do
139
+ expect(described_class::Flay).to receive :load
140
+ end
141
+
142
+ it "[loads reek]" do
143
+ expect(described_class::Reek).to receive :load
144
+ end
145
+
146
+ it "[loads roodi]" do
147
+ expect(described_class::Roodi).to receive :load
148
+ end
149
+
150
+ it "[loads saikuro]" do
151
+ expect(described_class::Saikuro).to receive :load
152
+ end
153
+ end
154
+
155
+ describe ".load" do
156
+
157
+ subject { try_in_sandbox { described_class.load } }
158
+
159
+ context "when metric_fu.yml is absent" do
160
+
161
+ include_context "without metric_fu.yml"
162
+
163
+ it_behaves_like "environment setter"
164
+ it_behaves_like "verbose setter"
165
+ it_behaves_like "metrics selector"
166
+ it_behaves_like "folders setter"
167
+ it_behaves_like "metrics loader"
168
+ end
169
+
170
+ context "when metric_fu.yml is present" do
171
+
172
+ include_context "with metric_fu.yml"
173
+
174
+ it_behaves_like "environment setter"
175
+ it_behaves_like "verbose setter"
176
+ it_behaves_like "metrics selector"
177
+ it_behaves_like "folders setter"
178
+ it_behaves_like "metrics loader"
179
+ end
180
+ end
181
+ end
@@ -0,0 +1,102 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "pippi"
4
+
5
+ describe Hexx::Suit::Metrics::Pippi, :sandbox do
6
+
7
+ shared_context "without pippi.yml" do
8
+
9
+ let(:options) do
10
+ { "checkset" => "basic", "output" => "tmp/pippi/output.log" }
11
+ end
12
+ end
13
+
14
+ shared_context "with pippi.yml" do
15
+
16
+ let(:options) do
17
+ { "checkset" => "training", "output" => "custom/pippi.log" }
18
+ end
19
+
20
+ before { prepare_settings options, "config/metrics/pippi.yml" }
21
+ end
22
+
23
+ shared_examples "environments loader" do
24
+
25
+ before { ENV["USE_PIPPI"] = nil }
26
+ before { ENV["PIPPI_OUTPUT"] = nil }
27
+
28
+ it "[sets USE_PIPPI]" do
29
+ expect { subject }.to change { ENV["USE_PIPPI"] }.to "true"
30
+ end
31
+
32
+ it "[sets PIPPI_OUTPUT]" do
33
+ expect { subject }.to change { ENV["PIPPI_OUTPUT"] }.to options["output"]
34
+ end
35
+ end
36
+
37
+ shared_examples "file creator" do
38
+
39
+ before { subject }
40
+
41
+ it "[prepares the output file]" do
42
+ expect(options["output"]).to be_present_in_sandbox
43
+ end
44
+ end
45
+
46
+ shared_examples "metric runner" do
47
+
48
+ after { subject }
49
+
50
+ it "[runs the metric]" do
51
+ expect(::Pippi::AutoRunner).to receive(:new) do |settings|
52
+ expect(settings[:checkset]).to eq options["checkset"]
53
+ expect(settings[:io]).to be_kind_of ::File
54
+ expect(settings[:io].path).to eq options["output"]
55
+ end
56
+ end
57
+ end
58
+
59
+ describe ".load" do
60
+
61
+ subject { try_in_sandbox { described_class.load } }
62
+
63
+ context "when pippi.yml is absent" do
64
+
65
+ include_context "without pippi.yml"
66
+
67
+ it_behaves_like "environments loader"
68
+ it_behaves_like "file creator"
69
+ end
70
+
71
+ context "when pippi.yml is present" do
72
+
73
+ include_context "with pippi.yml"
74
+
75
+ it_behaves_like "environments loader"
76
+ it_behaves_like "file creator"
77
+ end
78
+ end
79
+
80
+ describe ".run" do
81
+
82
+ subject { try_in_sandbox { described_class.run } }
83
+
84
+ context "when pippi.yml is absent" do
85
+
86
+ include_context "with pippi.yml"
87
+
88
+ it_behaves_like "environments loader"
89
+ it_behaves_like "file creator"
90
+ it_behaves_like "metric runner"
91
+ end
92
+
93
+ context "when pippi.yml is present" do
94
+
95
+ include_context "without pippi.yml"
96
+
97
+ it_behaves_like "environments loader"
98
+ it_behaves_like "file creator"
99
+ it_behaves_like "metric runner"
100
+ end
101
+ end
102
+ end