metric_fu 4.12.0 → 4.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 17c8fa2540d144f89979c7f5586a71c3889a29f5
4
- data.tar.gz: 23514588a8ce5ab8ebea208c91874c220db2a1fc
2
+ SHA256:
3
+ metadata.gz: 8ff6ebbe956db6bea6a6c659009c6b6d82cfd55bb307bab83fef44c84bc5ab62
4
+ data.tar.gz: f6c2186a24106cdaedebb726b1d6105bfa78133fa0634680312a432b1c6a6e4e
5
5
  SHA512:
6
- metadata.gz: 81f84088449c69e96c1e3830e3d938e0cef39d6e81b68c69699924f71d6e012d3b4ef055d19df66ba067a59c202f2fd5f33bfafefae1b4817f678596f79ac232
7
- data.tar.gz: 3da37a9252de3c65890b68c5593b9cab45fdaf86a1b36f995c2a3f609787c22382810ab7d5eb3210c1275823eceeef937e2b6111baa52afb0925b823d059f485
6
+ metadata.gz: 727a55955630636b8c5a6e47e88a985f45fd33c1f5e5242a5cea410704b2eb9d4caf802a2a06f49b9f333ffc89be4792a73d322eb64e5f8d31505e677dd37c5a
7
+ data.tar.gz: 3f8687c5f52822478f00a675ece026125113898c2229fe3be251453d9b4cb4b27fdaa76b4ea85b9b9735339dce5e489c842379cf4dede48083013db028f89395
data/.gitignore CHANGED
@@ -20,3 +20,9 @@ tmp
20
20
  *.swp
21
21
  tags
22
22
  .idea
23
+
24
+ # rvm
25
+ .ruby-version
26
+ .ruby-gemset
27
+
28
+ .overcommit.yml
@@ -1,4 +1,3 @@
1
- sudo: false
2
1
  language: ruby
3
2
  bundler_args: --path vendor/bundle --jobs=3 --retry=3
4
3
  script: bundle exec rspec
@@ -9,14 +8,11 @@ before_install:
9
8
  - bundle config --local without local_development yard guard
10
9
  rvm:
11
10
  # 2.1, not 2.1.0 until fixed https://github.com/travis-ci/travis-ci/issues/2220
12
- - 2.2
13
- - 2.1
14
- - 2.0.0
15
- - 1.9.2
16
- - 1.9.3
11
+ - 2.5
12
+ - 2.6
13
+ - 2.7
17
14
  - jruby
18
- - "rbx-2"
19
15
  matrix:
20
16
  allow_failures:
21
- - rvm: rbx-2
17
+ - rvm: jruby
22
18
  fast_finish: true
@@ -21,6 +21,7 @@ jscruggs
21
21
  David Chelimsky
22
22
  adrien
23
23
  Jay Zeschin
24
+ Greg Allen
24
25
  Alex Rothenberg
25
26
  calveto
26
27
  Avdi Grimm
@@ -36,8 +37,8 @@ unknown
36
37
  Micah Geisel
37
38
  Extrovert
38
39
  Ben Turner
39
- KAKUTANI Shintaro
40
40
  Andrew Timberlake
41
+ KAKUTANI Shintaro
41
42
  Guilherme Souza
42
43
  Przemysław Dąbek
43
44
  carlost
@@ -60,17 +61,16 @@ ff-cviradiya
60
61
  khall
61
62
  Stefan Huber
62
63
  Todd A. Jacobs
63
- René Föhring
64
+ jayzes
65
+ Hans Hasselberg
64
66
  Scyllinice
65
67
  Bitdeli Chef
66
- Hans Hasselberg
67
- jayzes
68
+ René Föhring
68
69
  Matthew Gordon
69
70
  factorylabs
70
71
  Mike Ball
71
- Mike Szyndel
72
- Chris Ian Fiel
73
- Greg Allen
74
- Paul Elliott
75
72
  Guilherme Simões
73
+ Paul Elliott
76
74
  Joel Nimety
75
+ Chris Ian Fiel
76
+ Mike Szyndel
data/Gemfile CHANGED
@@ -1,23 +1,48 @@
1
1
  # encoding: utf-8
2
2
  source "https://rubygems.org"
3
3
 
4
- if RUBY_VERSION == "1.9.2"
4
+ if RUBY_VERSION >= '1.9.3'
5
+ gem "rubocop", platforms: :mri, groups: [:test, :local_development]
6
+ gem "activesupport", "~> 4.2"
7
+
8
+ if RUBY_VERSION > '2.3'
9
+ gem "json", ">= 2.0"
10
+ else
11
+ gem "json", "~> 1.7"
12
+ end
13
+ if RUBY_VERSION =~ /^2\.0\..*/
14
+ gem "unparser", "0.2.4"
15
+ elsif RUBY_VERSION =~ /^1\.9\.3.*/
16
+ gem "unparser", "0.2.4"
17
+ gem "json_pure", "2.0.1"
18
+ gem "mime-types", "2.99.3"
19
+ gem "rest-client", "1.8.0"
20
+ gem "addressable", "2.4.0"
21
+ gem "ffi", "1.9.14" # windows support
22
+ end
23
+ elsif RUBY_VERSION =~ /^1\.9\.2.*/
5
24
  # because of https://github.com/railsbp/rails_best_practices/blob/master/rails_best_practices.gemspec
6
25
  gem "activesupport", "~> 3.2"
7
26
  # because of https://github.com/troessner/reek/issues/334
8
27
  gem "reek", "~> 1.4.0"
9
28
  # rbp -> as -> i18n
10
- gem 'i18n', '0.6.11'
29
+ gem "i18n", "0.6.11"
11
30
  gem "parallel", "= 1.3.3" # 1.3.4 disallows 1.9.2
12
- else
13
- gem "rubocop", platforms: :mri, groups: [:test, :local_development]
31
+ gem "unparser", "0.1.5"
32
+ gem "json_pure", "2.0.1"
33
+ gem "mime-types", "2.99.3"
34
+ gem "rest-client", "1.8.0"
35
+ gem "json", "~> 1.7"
36
+ gem "addressable", "2.4.0"
37
+ gem "rainbow", "2.1.0"
38
+ gem "ffi", "1.9.14" # windows support
14
39
  end
15
40
 
16
41
  gemspec path: File.expand_path("..", __FILE__)
17
42
 
18
43
  platform :jruby do
19
44
  group :jruby do
20
- gem "jruby-openssl", "~> 0.8.5"
45
+ gem "jruby-openssl", "~> 0.9.17"
21
46
  end
22
47
  end
23
48
 
@@ -31,20 +56,3 @@ group :development do
31
56
  gem "rake", "~> 10.1.0"
32
57
  gem "yard", "~> 0.8.7", group: :yard
33
58
  end
34
-
35
- group :guard do
36
- gem "guard", "~> 1.8.1"
37
- gem "guard-bundler", "~> 1.0.0"
38
- gem "guard-rspec"
39
-
40
- # file system change event handling
41
- gem "listen", "~> 1.3.0"
42
- gem "rb-fchange", "~> 0.0.6", require: false
43
- gem "rb-fsevent", "~> 0.9.3", require: false
44
- gem "rb-inotify", "~> 0.9.0", require: false
45
-
46
- # notification handling
47
- gem "libnotify", "~> 0.8.0", require: false
48
- gem "rb-notifu", "~> 0.0.4", require: false
49
- gem "terminal-notifier-guard", "~> 1.5.3", require: false
50
- end
data/HISTORY.md CHANGED
@@ -4,13 +4,29 @@ Each change should fall into categories that would affect whether the release is
4
4
 
5
5
  As such, a _Feature_ would map to either major (breaking change) or minor. A _bug fix_ to a patch. And _misc_ is either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding tests would be patch level.
6
6
 
7
- ### Master [changes](https://github.com/metricfu/metric_fu/compare/v4.12.0...master)
7
+ ### [Unreleased](https://github.com/metricfu/metric_fu/compare/v4.13.0...master)
8
8
 
9
9
  * Breaking Changes
10
10
  * Features
11
11
  * Fixes
12
12
  * Misc
13
13
 
14
+ ### [4.13.0](https://github.com/metricfu/metric_fu/compare/v4.12.0...v4.13.0)
15
+
16
+ * Features
17
+ * Setup CI pipeline on AppVeyor and fixed specs. (Rasmus Bergholdt, #285, fixes #284)
18
+ * Upgraded roodi to v5.0.0 (Jonathan Keam, #287)
19
+ * Updated jruby-openssl and removed unused rb-notifu gem (Jonathan Keam, #290)
20
+ * Fixes
21
+ * Rails best practices options (Noah S-W, #264, #263)
22
+ * Fix deprecation warnings for Dir.exists? (Jared Szechy, #269)
23
+ * Fix specs (Luciano Sousa, #270)
24
+ * Fixed broken dependencies (Jonathan Keam, #279)
25
+ * FlogCli.flog must receive an expanded list of files (Rasmus Bergholdt, #282, fixes #273)
26
+ * Fix test warnings (Jonathan Keam, #289, addresses #288)
27
+ * Misc
28
+ * Add a Gitter chat badge to README.md (#259)
29
+
14
30
  ### [4.12.0](https://github.com/metricfu/metric_fu/compare/v4.11.4...v4.12.0)
15
31
 
16
32
  * Features
data/README.md CHANGED
@@ -1,9 +1,15 @@
1
- # MetricFu [![Gem Version](https://badge.fury.io/rb/metric_fu.png)](http://badge.fury.io/rb/metric_fu) [![Build Status](https://travis-ci.org/metricfu/metric_fu.png?branch=master)](http://travis-ci.org/metricfu/metric_fu)
1
+ # MetricFu [![Gem Version](https://badge.fury.io/rb/metric_fu.svg)](http://badge.fury.io/rb/metric_fu) [![Build Status](https://travis-ci.org/metricfu/metric_fu.svg?branch=master)](http://travis-ci.org/metricfu/metric_fu)
2
2
 
3
- [![Code Climate](https://codeclimate.com/github/metricfu/metric_fu.png)](https://codeclimate.com/github/metricfu/metric_fu) [![Inline docs](http://inch-ci.org/github/metricfu/metric_fu.png)](http://inch-ci.org/github/metricfu/metric_fu) [![Dependency Status](https://gemnasium.com/metricfu/metric_fu.png)](https://gemnasium.com/metricfu/metric_fu)
3
+ [![Join the chat at https://gitter.im/metricfu/metric_fu](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/metricfu/metric_fu?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+
5
+ [![Code Climate](https://codeclimate.com/github/metricfu/metric_fu.svg)](https://codeclimate.com/github/metricfu/metric_fu) [![Inline docs](http://inch-ci.org/github/metricfu/metric_fu.svg)](http://inch-ci.org/github/metricfu/metric_fu)
4
6
 
5
7
  [Rdoc](http://rdoc.info/github/metricfu/metric_fu/)
6
8
 
9
+ ## Maintenance
10
+
11
+ MetricFu needs maintainers. If you are up for helping out, please left a note in [issue 280]( https://github.com/metricfu/metric_fu/issues/280). MetricFu is free and open source code that belongs to everyone. Benjamin (@bf4) hasn't been working on MetricFu for a while, which is a great opportunity for you to step up!
12
+
7
13
  ## Installation
8
14
 
9
15
  gem install metric_fu
@@ -47,7 +53,6 @@ See:
47
53
 
48
54
  ## Documentation
49
55
 
50
-
51
56
  MetricFu will attempt to load configuration data from a
52
57
  `.metrics` file, if present in your repository root.
53
58
 
@@ -87,9 +92,67 @@ MetricFu.configuration.configure_metrics.each do |metric|
87
92
  end
88
93
  ```
89
94
 
90
- ## Formatters
95
+ ### Rails Best Practices
96
+
97
+ ```ruby
98
+ MetricFu::Configuration.run do |config|
99
+ config.configure_metric(:rails_best_practices) do |rbp|
100
+ rbp.silent = true
101
+ rbp.exclude = ["config/chef"]
102
+ end
103
+ end
104
+ ```
105
+
106
+ ### Coverage Metrics
107
+
108
+ ```ruby
109
+ MetricFu::Configuration.run do |config|
110
+ config.configure_metric(:rcov) do |rcov|
111
+ rcov.coverage_file = MetricFu.run_path.join("coverage/rcov/rcov.txt")
112
+ rcov.enable
113
+ rcov.activate
114
+ end
115
+ end
116
+ ```
117
+
118
+ If you want metric_fu to actually run rcov itself (1.8 only), don't specify an external file to read from
119
+
120
+ #### Rcov metrics with Ruby 1.8
121
+
122
+ To generate the same metrics metric_fu has been generating run from the root of your project before running metric_fu
123
+
124
+ ```shell
125
+ RAILS_ENV=test rcov $(ruby -e "puts Dir['{spec,test}/**/*_{spec,test}.rb'].join(' ')") --sort coverage --no-html --text-coverage --no-color --profile --exclude-only '.*' --include-file "\Aapp,\Alib" -Ispec > coverage/rcov/rcov.txt
126
+ ```
127
+
128
+ #### Simplecov metrics with Ruby 1.9 and 2.0
129
+
130
+ Add to your Gemfile or otherwise install
131
+
132
+ ```ruby
133
+ gem 'simplecov'
134
+ ```
135
+
136
+ Modify your [spec_helper](https://github.com/metricfu/metric_fu/blob/master/spec/spec_helper.rb) as per the SimpleCov docs and run your tests before running metric_fu
137
+
138
+ ```ruby
139
+ #in your spec_helper
140
+ require 'simplecov'
141
+ require 'metric_fu/metrics/rcov/simplecov_formatter'
142
+ SimpleCov.formatter = SimpleCov::Formatter::MetricFu
143
+ # or
144
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
145
+ SimpleCov::Formatter::HTMLFormatter,
146
+ SimpleCov::Formatter::MetricFu
147
+ ]
148
+ SimpleCov.start
149
+ ```
150
+
151
+ Additionally, the `coverage_file` path must be specified as above and must exist.
91
152
 
92
- ### Built-in Formatters
153
+ ### Formatters
154
+
155
+ #### Built-in Formatters
93
156
 
94
157
  By default, metric_fu will use the built-in html formatter to generate HTML reports for each metric with pretty graphs.
95
158
 
@@ -125,7 +188,7 @@ MetricFu::Configuration.run do |config|
125
188
  end
126
189
  ```
127
190
 
128
- ### Custom Formatters
191
+ #### Custom Formatters
129
192
 
130
193
  You can customize metric_fu's output format with a custom formatter.
131
194
 
@@ -161,7 +224,7 @@ your .metrics configuration file.
161
224
 
162
225
  For instance, to require a formatter in your app's lib directory `require './lib/my_custom_formatter.rb'`
163
226
 
164
- ## Configure Graph Engine
227
+ ### Configure Graph Engine
165
228
 
166
229
  By default, MetricFu uses the Bluff (JavaScript) graph engine.
167
230
 
@@ -178,56 +241,6 @@ MetricFu.configuration.configure_graph_engine(:highcharts)
178
241
  Notice: There was previously a :gchart option.
179
242
  It was not properly deprecated in the 4.x series.
180
243
 
181
- ### Using Coverage Metrics
182
-
183
- in your .metrics file add the below to run pre-generated metrics
184
-
185
- ```ruby
186
- MetricFu::Configuration.run do |config|
187
- config.configure_metric(:rcov) do |rcov|
188
- rcov.coverage_file = MetricFu.run_path.join("coverage/rcov/rcov.txt")
189
- rcov.enable
190
- rcov.activate
191
- end
192
- end
193
- ```
194
-
195
- If you want metric_fu to actually run rcov itself (1.8 only), don't specify an external file to read from
196
-
197
- #### Rcov metrics with Ruby 1.8
198
-
199
- To generate the same metrics metric_fu has been generating run from the root of your project before running metric_fu
200
-
201
- ```shell
202
- RAILS_ENV=test rcov $(ruby -e "puts Dir['{spec,test}/**/*_{spec,test}.rb'].join(' ')") --sort coverage --no-html --text-coverage --no-color --profile --exclude-only '.*' --include-file "\Aapp,\Alib" -Ispec > coverage/rcov/rcov.txt
203
- ```
204
-
205
- #### Simplecov metrics with Ruby 1.9 and 2.0
206
-
207
- Add to your Gemfile or otherwise install
208
-
209
- ```ruby
210
- gem 'simplecov'
211
- ```
212
-
213
- Modify your [spec_helper](https://github.com/metricfu/metric_fu/blob/master/spec/spec_helper.rb) as per the SimpleCov docs and run your tests before running metric_fu
214
-
215
- ```ruby
216
- #in your spec_helper
217
- require 'simplecov'
218
- require 'metric_fu/metrics/rcov/simplecov_formatter'
219
- SimpleCov.formatter = SimpleCov::Formatter::MetricFu
220
- # or
221
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
222
- SimpleCov::Formatter::HTMLFormatter,
223
- SimpleCov::Formatter::MetricFu
224
- ]
225
- SimpleCov.start
226
- ```
227
-
228
- Additionally, the `coverage_file` path must be specified as above
229
- and must exist.
230
-
231
244
  ## Common problems / debugging
232
245
 
233
246
  - ['ArgumentError; message invalid byte sequence in US-ASCII'](https://github.com/metricfu/metric_fu/issues/215) may be caused by having a default external encoding that is not UTF-8. You can see this in the output of `metric_fu --debug`
@@ -0,0 +1,34 @@
1
+ version: '{build}'
2
+ image:
3
+ - Visual Studio 2019
4
+
5
+ skip_tags: true
6
+
7
+ environment:
8
+ matrix:
9
+ - RUBY_VERSION: 25
10
+ - RUBY_VERSION: 25-x64
11
+ - RUBY_VERSION: 26
12
+ - RUBY_VERSION: 26-x64
13
+ - RUBY_VERSION: 27
14
+ - RUBY_VERSION: 27-x64
15
+
16
+ install:
17
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
18
+ - gem install bundler
19
+ - bundle config force_ruby_platform true
20
+ - bundle install --path=vendor/bundle --retry=3 --jobs=3
21
+
22
+ cache:
23
+ - vendor/bundle
24
+
25
+ build: off
26
+
27
+ before_test:
28
+ - ruby -v
29
+ - gem -v
30
+ - bundle -v
31
+
32
+ test_script:
33
+ - bundle exec rspec
34
+ - bundle exec ruby -Ilib bin/metric_fu --no-open
@@ -0,0 +1 @@
1
+ 5af713f345549aa574af94d5790ec5360d61aa9ff9dce867da339f5a86e1d2d39c23d025434dd98fc04e0912b6a6da64f271663242a5aa75cbf15cac1c9c73e1
@@ -0,0 +1 @@
1
+ e57d3944216f0d2f9ff06ddabae68cc240510df5a3b346739d866c9dc9e86d5bc7e341efd13f5bc34f5d06bdb90cf455a4491dfc65d2f197bc0ca616ea911f7c
@@ -20,6 +20,15 @@ module MetricFu
20
20
  "MetricFu"
21
21
  end
22
22
 
23
+ def with_run_dir(dir, &block)
24
+ old_dir = run_dir
25
+ self.run_dir = dir
26
+
27
+ block.call
28
+
29
+ self.run_dir = old_dir
30
+ end
31
+
23
32
  def run_dir
24
33
  @run_dir ||= Dir.pwd
25
34
  end
@@ -12,7 +12,7 @@ module MetricFu
12
12
  REQUIREMENT_LIST = /(?<qr1>["'])(?<req1>#{REQUIREMENT})\k<qr1>(?:[ \t]*,[ \t]*(?<qr2>["'])(?<req2>#{REQUIREMENT})\k<qr2>)?/
13
13
  REQUIREMENTS = /(?:#{REQUIREMENT_LIST}|\[[ \t]*#{REQUIREMENT_LIST}[ \t]*\])/
14
14
  COMMENT = /(#[^\n]*)?/
15
- ADD_DEPENDENCY_CALL = /^[ \t]*\w+\.add(?<type>_runtime|_development)?_dependency\(?[ \t]*#{QUOTED_GEM_NAME}(?:[ \t]*,[ \t]*#{REQUIREMENTS})?[ \t]*\)?[ \t]*#{COMMENT}$/
15
+ ADD_DEPENDENCY_CALL = /^[ \t]*\w+\.add(?<type>_runtime|_development)?_dependency\(?[ \t]*#{QUOTED_GEM_NAME}(.freeze)?(?:[ \t]*,[ \t]*#{REQUIREMENTS})?[ \t]*\)?[ \t]*#{COMMENT}$/
16
16
 
17
17
  def initialize
18
18
  @gem_spec = File.open(gemspec, "rb") { |f| f.readlines }
@@ -124,7 +124,7 @@ module MetricFu
124
124
  end
125
125
 
126
126
  def self.not_implemented
127
- raise <<-EOF
127
+ raise NotImplementedError.new <<-EOF
128
128
  Required method #{caller[0]} not implemented in #{__FILE__}.
129
129
  This method must be implemented by a concrete class descending
130
130
  from Generator. See generator class documentation for more
@@ -59,7 +59,7 @@ module MetricFu
59
59
 
60
60
  # Add the 'app' directory if we're running within rails.
61
61
  def set_code_dirs
62
- @directories["code_dirs"] = %w(app lib).select { |dir| Dir.exists?(dir) }
62
+ @directories["code_dirs"] = %w(app lib).select { |dir| Dir.exist?(dir) }
63
63
  end
64
64
  end
65
65
 
@@ -13,7 +13,7 @@ module MetricFu
13
13
  options[:continue] ? "--continue" : nil,
14
14
  ].compact
15
15
  @flogger = FlogCLI.new parse_options
16
- @flogger.flog *options[:dirs_to_flog]
16
+ @flogger.flog *files_to_flog
17
17
  end
18
18
 
19
19
  def analyze
@@ -51,6 +51,18 @@ module MetricFu
51
51
  end
52
52
  end
53
53
  end
54
+
55
+ private
56
+
57
+ def files_to_flog
58
+ options[:dirs_to_flog].flatten.map do |p|
59
+ if File.directory? p then
60
+ Dir[File.join(p, '**/*.{rb,rake}')]
61
+ else
62
+ p
63
+ end
64
+ end.flatten
65
+ end
54
66
  end
55
67
 
56
68
  class MethodContainer
@@ -12,18 +12,10 @@ module MetricFu
12
12
  def to_hash
13
13
  {
14
14
  "location" => location.to_hash,
15
- "details" => stringify_keys(problems),
15
+ "details" => MetricFu::Utility.stringify_keys(problems),
16
16
  }
17
17
  end
18
18
 
19
- def stringify_keys(hash)
20
- result = {}
21
- hash.each do |key, value|
22
- result[key.to_s] = value
23
- end
24
- result
25
- end
26
-
27
19
  # @todo redo as item,value, options = {}
28
20
  # Note that the other option for 'details' is :detailed (this isn't
29
21
  # at all clear from this method itself
@@ -4,10 +4,14 @@ module MetricFu
4
4
  :rails_best_practices
5
5
  end
6
6
 
7
+ def initialize(options = {})
8
+ super(MetricFu::Utility.stringify_keys(options))
9
+ end
10
+
7
11
  def emit
8
12
  mf_debug "** Rails Best Practices"
9
13
  path = "."
10
- analyzer = ::RailsBestPractices::Analyzer.new(path, "silent" => true)
14
+ analyzer = ::RailsBestPractices::Analyzer.new(path, options)
11
15
  analyzer.analyze
12
16
  @output = analyzer.errors
13
17
  end
@@ -5,7 +5,10 @@ module MetricFu
5
5
  end
6
6
 
7
7
  def default_run_options
8
- {}
8
+ {
9
+ silent: true,
10
+ exclude: []
11
+ }
9
12
  end
10
13
 
11
14
  def has_graph?
@@ -15,11 +15,13 @@ module MetricFu
15
15
  end
16
16
 
17
17
  def run!(files, config_files)
18
- examiner.new(files, config_files)
18
+ files.map do |file|
19
+ examiner.new(File.new(file), filter_by_smells: config_files)
20
+ end
19
21
  end
20
22
 
21
23
  def analyze
22
- @matches = @output.smells.group_by(&:source).collect do |file_path, smells|
24
+ @matches = @output.flat_map(&:smells).group_by(&:source).collect do |file_path, smells|
23
25
  { file_path: file_path,
24
26
  code_smells: analyze_smells(smells) }
25
27
  end
@@ -24,6 +24,7 @@ module MetricFu
24
24
  end
25
25
 
26
26
  def html_filename(file)
27
+ require "digest"
27
28
  file = Digest::SHA1.hexdigest(file)[0..29]
28
29
  "#{file.gsub(%r{/}, '_')}.html"
29
30
  end
@@ -19,6 +19,14 @@ module MetricFu
19
19
  end
20
20
  end
21
21
 
22
+ def stringify_keys(hash)
23
+ result = {}
24
+ hash.each do |key, value|
25
+ result[key.to_s] = value
26
+ end
27
+ result
28
+ end
29
+
22
30
  def strip_escape_codes(text)
23
31
  text.gsub(ESCAPE_CODES_PATTERN, "")
24
32
  end
@@ -1,7 +1,7 @@
1
1
  module MetricFu
2
2
  class Version
3
3
  MAJOR = "4"
4
- MINOR = "12"
4
+ MINOR = "13"
5
5
  PATCH = "0"
6
6
  PRE = ""
7
7
  end
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.signing_key = File.join(Gem.user_home, ".ssh", "gem-private_key.pem")
20
20
  end
21
21
 
22
- s.rubyforge_project = "metric_fu"
23
22
  s.license = "MIT"
24
23
  s.platform = Gem::Platform::RUBY
25
24
  s.version = MetricFu::VERSION
@@ -34,22 +33,20 @@ Gem::Specification.new do |s|
34
33
  s.files = files
35
34
  s.test_files = test_files
36
35
  s.executables = executables
37
- s.default_executable = "metric_fu"
38
36
  s.require_paths = ["lib"]
39
37
 
40
- s.has_rdoc = true
41
38
  s.extra_rdoc_files = ["HISTORY.md", "CONTRIBUTING.md", "TODO.md", "MIT-LICENSE"]
42
39
  s.rdoc_options = ["--main", "README.md"]
43
40
 
44
41
  # metric dependencies
45
42
  s.add_runtime_dependency "flay", [">= 2.0.1", "~> 2.1"]
46
- s.add_runtime_dependency "churn", ["~> 0.0.35"]
43
+ s.add_runtime_dependency "churn", [">= 1.0.2", "~> 1.0"]
47
44
  s.add_runtime_dependency "flog", [">= 4.1.1", "~> 4.1"]
48
- s.add_runtime_dependency "reek", [">= 1.3.4", "< 3.0"]
45
+ s.add_runtime_dependency "reek", [">= 5.4.0"]
49
46
  s.add_runtime_dependency "cane", [">= 2.5.2", "~> 2.5"]
50
47
  s.add_runtime_dependency "rails_best_practices", [">= 1.14.3", "~> 1.14"]
51
48
  s.add_runtime_dependency "metric_fu-Saikuro", [">= 1.1.3", "~> 1.1"]
52
- s.add_runtime_dependency "roodi", ["~> 3.1"]
49
+ s.add_runtime_dependency "roodi", ["~> 5.0.0"]
53
50
  s.add_runtime_dependency "code_metrics", ["~> 0.1"]
54
51
 
55
52
  # other dependencies
@@ -67,5 +64,5 @@ Gem::Specification.new do |s|
67
64
  s.add_development_dependency "test_construct"
68
65
  # ensure we have a JSON parser
69
66
  s.add_development_dependency "json"
70
- s.add_development_dependency "simplecov", "~> 0.9"
67
+ s.add_development_dependency "simplecov", "< 0.18"
71
68
  end
@@ -42,19 +42,19 @@ describe MetricFu::Generator do
42
42
  end
43
43
 
44
44
  describe "#generate_result" do
45
- it "should raise an error when calling #emit" do
45
+ it "should raise an error when calling #emit" do
46
46
  @abstract_class = MetricFu::Generator.new
47
- expect { @abstract_class.generate_result }.to raise_error
47
+ expect { @abstract_class.generate_result }.to raise_error NotImplementedError
48
48
  end
49
49
 
50
50
  it "should call #analyze" do
51
51
  @abstract_class = MetricFu::Generator.new
52
- expect { @abstract_class.generate_result }.to raise_error
52
+ expect { @abstract_class.generate_result }.to raise_error NotImplementedError
53
53
  end
54
54
 
55
55
  it "should call #to_h" do
56
56
  @abstract_class = MetricFu::Generator.new
57
- expect { @abstract_class.generate_result }.to raise_error
57
+ expect { @abstract_class.generate_result }.to raise_error NotImplementedError
58
58
  end
59
59
  end
60
60
 
@@ -4,7 +4,10 @@ describe MetricFu do
4
4
  it "loads the .metrics file" do
5
5
  # Global only for testing that this file gets loaded
6
6
  $metric_file_loaded = false
7
- MetricFu.loader.load_user_configuration
7
+ MetricFu.with_run_dir "spec/support" do
8
+ MetricFu.loader.load_user_configuration
9
+ end
10
+
8
11
  expect($metric_file_loaded).to be_truthy
9
12
  end
10
13
  end
@@ -14,7 +14,8 @@ describe MetricFu::FlogGenerator do
14
14
  it "should look for files and flog them" do
15
15
  expect(FlogCLI).to receive(:parse_options).with(["--all", "--continue"]).and_return("options")
16
16
  expect(FlogCLI).to receive(:new).with("options").and_return(flogger = double("flogger"))
17
- expect(flogger).to receive(:flog).with("lib")
17
+ files_to_flog = Dir[File.join('lib', '**/*.{rb,rake}')]
18
+ expect(flogger).to receive(:flog).with(*files_to_flog)
18
19
  @flog.emit
19
20
  end
20
21
  end
@@ -20,9 +20,21 @@ describe MetricFu::Configuration, "for rails_best_practices" do
20
20
  end
21
21
  end
22
22
 
23
- it "should set @rails_best_practices to {}" do
23
+ it "should default @rails_best_practices to { :silent => true }" do
24
24
  load_metric "rails_best_practices"
25
- expect(MetricFu::Metric.get_metric(:rails_best_practices).run_options).to eql({})
25
+ rbp = MetricFu::MetricRailsBestPractices.new
26
+ expect(rbp.run_options).to eq(exclude: [], silent: true)
27
+ end
28
+
29
+ it "can configure @rails_best_practices 'exclude' using the sugar" do
30
+ load_metric "rails_best_practices"
31
+ rbp = MetricFu::Metric.get_metric(:rails_best_practices)
32
+ rbp.exclude = ["config/chef"]
33
+ expect(rbp.run_options).to eq(
34
+ exclude: ["config/chef"],
35
+ silent: true
36
+ )
37
+
26
38
  end
27
39
  end
28
40
 
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+
2
3
  MetricFu.metrics_require { "reek/generator" }
3
4
 
4
5
  describe MetricFu::ReekGenerator do
@@ -7,7 +8,7 @@ describe MetricFu::ReekGenerator do
7
8
  let(:files_to_analyze) { ["lib/foo.rb", "lib/bar.rb"] }
8
9
  let(:reek) { MetricFu::ReekGenerator.new(options) }
9
10
 
10
- before :each do
11
+ before(:each) do
11
12
  allow(reek).to receive(:files_to_analyze).and_return(files_to_analyze)
12
13
  end
13
14
 
@@ -42,8 +43,8 @@ describe MetricFu::ReekGenerator do
42
43
  before :each do
43
44
  MetricFu::Configuration.run {}
44
45
  allow(File).to receive(:directory?).and_return(true)
45
- @reek = MetricFu::ReekGenerator.new
46
- @examiner = @reek.send(:examiner)
46
+ @generator = MetricFu::ReekGenerator.new
47
+ @examiner = @generator.send(:examiner)
47
48
  @smell_warning = Reek.const_defined?(:SmellWarning) ? Reek.const_get(:SmellWarning) : Reek.const_get(:Smells).const_get(:SmellWarning)
48
49
  if @smell_warning.instance_methods.include?(:subclass)
49
50
  @smell_warning.send(:alias_method, :smell_type, :subclass)
@@ -99,9 +100,11 @@ describe MetricFu::ReekGenerator do
99
100
  smell_type: "Duplication",
100
101
  lines: [6, 9])
101
102
  ]
102
- @lines = instance_double(@examiner, smells: @smells)
103
- @reek.instance_variable_set(:@output, @lines)
104
- @matches = @reek.analyze
103
+ @examiners = [
104
+ instance_double(Reek::Examiner, smells: @smells)
105
+ ]
106
+ @generator.instance_variable_set(:@output, @examiners)
107
+ @matches = @generator.analyze
105
108
  end
106
109
 
107
110
  it "should find the code smell's line numbers" do
@@ -143,9 +146,11 @@ describe MetricFu::ReekGenerator do
143
146
  subclass: "Duplication",
144
147
  lines: [2, 4]),
145
148
  ]
146
- @lines = instance_double(@examiner, smells: @smells)
147
- @reek.instance_variable_set(:@output, @lines)
148
- @matches = @reek.analyze
149
+ @examiners = [
150
+ instance_double(Reek::Examiner, smells: @smells)
151
+ ]
152
+ @generator.instance_variable_set(:@output, @examiners)
153
+ @matches = @generator.analyze
149
154
  end
150
155
 
151
156
  it "uses the subclass field to find the smell type" do
@@ -154,11 +159,40 @@ describe MetricFu::ReekGenerator do
154
159
  end
155
160
  end
156
161
 
162
+ context "with real output, not mocked nor doubled" do
163
+ let(:result) do
164
+ {
165
+ file_path: "spec/support/samples/reek/alfa.rb",
166
+ code_smells: [
167
+ {
168
+ lines: [1],
169
+ message: "has unused parameter 'echo'",
170
+ method: "foo",
171
+ type: "UnusedParameters"
172
+ }
173
+ ]
174
+ }
175
+ end
176
+
177
+ it "returns real data" do
178
+ MetricFu.with_run_dir File.expand_path("../../..", __FILE__) do
179
+ @generator = MetricFu::ReekGenerator.new(dirs_to_reek: ["spec/support/samples"])
180
+ @generator.emit
181
+
182
+ @matches = @generator.analyze
183
+
184
+ expect(@matches.first).to eq(result)
185
+ end
186
+ end
187
+ end
188
+
157
189
  context "without reek warnings" do
158
190
  before :each do
159
- @lines = instance_double(@examiner, smells: [])
160
- @reek.instance_variable_set(:@output, @lines)
161
- @matches = @reek.analyze
191
+ @examiners = [
192
+ instance_double(Reek::Examiner, smells: [])
193
+ ]
194
+ @generator.instance_variable_set(:@output, @examiners)
195
+ @matches = @generator.analyze
162
196
  end
163
197
 
164
198
  it "returns empty analysis" do
@@ -178,7 +178,7 @@ describe MetricFu::Template do
178
178
  it "returns a link with that absolute path" do
179
179
  name = "/some/file.rb"
180
180
  result = @template.send(:link_to_filename, name)
181
- expect(result).to eq("<a href='file:///some/file.rb'>/some/file.rb</a>")
181
+ expect(result).to match("<a href='file://(.:)?/some/file.rb'>/some/file.rb</a>")
182
182
  end
183
183
  end
184
184
 
@@ -2,8 +2,27 @@
2
2
  require "spec_helper"
3
3
 
4
4
  describe MetricFu do
5
+ before do
6
+ MetricFu.run_dir = Dir.pwd
7
+ MetricFu.report_name = nil
8
+ end
9
+
10
+ describe ".with_run_dir" do
11
+ it "temporarily uses a specified `run_dir`" do
12
+ expect(MetricFu.run_dir).to eq(Dir.pwd)
13
+
14
+ MetricFu.with_run_dir "spec/dummy" do
15
+ expect(MetricFu.run_dir).to eq("spec/dummy")
16
+ end
17
+
18
+ expect(MetricFu.run_dir).to eq(Dir.pwd)
19
+ end
20
+ end
21
+
5
22
  specify "the default report_name is the run directory base name" do
6
- expect(MetricFu.report_name).to eq("dummy")
23
+ MetricFu.with_run_dir "spec/support" do
24
+ expect(MetricFu.report_name).to eq("support")
25
+ end
7
26
  end
8
27
 
9
28
  specify "the user can set the report_name" do
@@ -36,19 +36,11 @@ RSpec.configure do |config|
36
36
  # :each every describe block
37
37
  # :all every it block
38
38
 
39
- def run_dir
40
- File.expand_path("dummy", File.dirname(__FILE__))
41
- end
42
-
43
- config.before(:suite) do
44
- MetricFu.run_dir = run_dir
45
- end
46
-
47
39
  config.after(:suite) do
48
40
  cleanup_fs
49
41
  end
50
42
 
51
- config.after(:each) do
43
+ config.append_after do
52
44
  MetricFu.reset
53
45
  end
54
46
  end
File without changes
@@ -0,0 +1 @@
1
+ def foo(echo); end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metric_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.0
4
+ version: 4.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Scruggs
@@ -10,7 +10,7 @@ authors:
10
10
  - Petrik de Heus
11
11
  - Grant McInnes
12
12
  - Nick Quaranto
13
- - "Édouard Brière"
13
+ - Édouard Brière
14
14
  - Carl Youngblood
15
15
  - Richard Huang
16
16
  - Dan Mayer
@@ -20,7 +20,7 @@ autorequire:
20
20
  bindir: bin
21
21
  cert_chain:
22
22
  - certs/bf4.pem
23
- date: 2015-06-18 00:00:00.000000000 Z
23
+ date: 2020-06-03 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: flay
@@ -46,16 +46,22 @@ dependencies:
46
46
  name: churn
47
47
  requirement: !ruby/object:Gem::Requirement
48
48
  requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 1.0.2
49
52
  - - "~>"
50
53
  - !ruby/object:Gem::Version
51
- version: 0.0.35
54
+ version: '1.0'
52
55
  type: :runtime
53
56
  prerelease: false
54
57
  version_requirements: !ruby/object:Gem::Requirement
55
58
  requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.2
56
62
  - - "~>"
57
63
  - !ruby/object:Gem::Version
58
- version: 0.0.35
64
+ version: '1.0'
59
65
  - !ruby/object:Gem::Dependency
60
66
  name: flog
61
67
  requirement: !ruby/object:Gem::Requirement
@@ -82,20 +88,14 @@ dependencies:
82
88
  requirements:
83
89
  - - ">="
84
90
  - !ruby/object:Gem::Version
85
- version: 1.3.4
86
- - - "<"
87
- - !ruby/object:Gem::Version
88
- version: '3.0'
91
+ version: 5.4.0
89
92
  type: :runtime
90
93
  prerelease: false
91
94
  version_requirements: !ruby/object:Gem::Requirement
92
95
  requirements:
93
96
  - - ">="
94
97
  - !ruby/object:Gem::Version
95
- version: 1.3.4
96
- - - "<"
97
- - !ruby/object:Gem::Version
98
- version: '3.0'
98
+ version: 5.4.0
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: cane
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -162,14 +162,14 @@ dependencies:
162
162
  requirements:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: '3.1'
165
+ version: 5.0.0
166
166
  type: :runtime
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '3.1'
172
+ version: 5.0.0
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: code_metrics
175
175
  requirement: !ruby/object:Gem::Requirement
@@ -286,16 +286,16 @@ dependencies:
286
286
  name: simplecov
287
287
  requirement: !ruby/object:Gem::Requirement
288
288
  requirements:
289
- - - "~>"
289
+ - - "<"
290
290
  - !ruby/object:Gem::Version
291
- version: '0.9'
291
+ version: '0.18'
292
292
  type: :development
293
293
  prerelease: false
294
294
  version_requirements: !ruby/object:Gem::Requirement
295
295
  requirements:
296
- - - "~>"
296
+ - - "<"
297
297
  - !ruby/object:Gem::Version
298
- version: '0.9'
298
+ version: '0.18'
299
299
  description: Code metrics from Flog, Flay, Saikuro, Churn, Reek, Roodi, Code Statistics,
300
300
  and Rails Best Practices. (and optionally RCov)
301
301
  email: github@benjaminfleischer.com
@@ -333,6 +333,7 @@ files:
333
333
  - README.md
334
334
  - Rakefile
335
335
  - TODO.md
336
+ - appveyor.yml
336
337
  - bin/metric_fu
337
338
  - bin/mf-cane
338
339
  - bin/mf-churn
@@ -348,6 +349,8 @@ files:
348
349
  - checksum/metric_fu-4.11.2.gem.sha512
349
350
  - checksum/metric_fu-4.11.3.gem.sha512
350
351
  - checksum/metric_fu-4.11.4.gem.sha512
352
+ - checksum/metric_fu-4.12.0.gem.sha512
353
+ - checksum/metric_fu-4.13.0.gem.sha512
351
354
  - checksum/metric_fu-4.2.0.gem.sha512
352
355
  - checksum/metric_fu-4.2.1.gem.sha512
353
356
  - checksum/metric_fu-4.3.0.gem.sha512
@@ -504,7 +507,6 @@ files:
504
507
  - spec/cli/helper_spec.rb
505
508
  - spec/dummy/.gitignore
506
509
  - spec/dummy/.gitkeep
507
- - spec/dummy/.metrics
508
510
  - spec/dummy/lib/.gitkeep
509
511
  - spec/dummy/lib/bad_encoding.rb
510
512
  - spec/dummy/spec/.gitkeep
@@ -596,10 +598,12 @@ files:
596
598
  - spec/shared/configured.rb
597
599
  - spec/shared/test_coverage.rb
598
600
  - spec/spec_helper.rb
601
+ - spec/support/.metrics
599
602
  - spec/support/deferred_garbaged_collection.rb
600
603
  - spec/support/helper_methods.rb
601
604
  - spec/support/matcher_create_file.rb
602
605
  - spec/support/matcher_create_files.rb
606
+ - spec/support/samples/reek/alfa.rb
603
607
  - spec/support/suite.rb
604
608
  - spec/support/test_fixtures.rb
605
609
  - spec/support/timeout.rb
@@ -626,8 +630,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
626
630
  - !ruby/object:Gem::Version
627
631
  version: 1.3.6
628
632
  requirements: []
629
- rubyforge_project: metric_fu
630
- rubygems_version: 2.4.6
633
+ rubygems_version: 3.1.2
631
634
  signing_key:
632
635
  specification_version: 4
633
636
  summary: A fistful of code metrics, with awesome templates and graphs
@@ -636,7 +639,6 @@ test_files:
636
639
  - spec/cli/helper_spec.rb
637
640
  - spec/dummy/.gitignore
638
641
  - spec/dummy/.gitkeep
639
- - spec/dummy/.metrics
640
642
  - spec/dummy/lib/.gitkeep
641
643
  - spec/dummy/lib/bad_encoding.rb
642
644
  - spec/dummy/spec/.gitkeep
@@ -728,13 +730,14 @@ test_files:
728
730
  - spec/shared/configured.rb
729
731
  - spec/shared/test_coverage.rb
730
732
  - spec/spec_helper.rb
733
+ - spec/support/.metrics
731
734
  - spec/support/deferred_garbaged_collection.rb
732
735
  - spec/support/helper_methods.rb
733
736
  - spec/support/matcher_create_file.rb
734
737
  - spec/support/matcher_create_files.rb
738
+ - spec/support/samples/reek/alfa.rb
735
739
  - spec/support/suite.rb
736
740
  - spec/support/test_fixtures.rb
737
741
  - spec/support/timeout.rb
738
742
  - spec/support/usage_test.rb
739
743
  - spec/usage_test_spec.rb
740
- has_rdoc: true