rubycritic 4.1.0 → 4.2.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
2
  SHA256:
3
- metadata.gz: 6d28dbb364926311a07893f4d5ee5253a1435c16e992d0c132ecf90c045a141c
4
- data.tar.gz: 05b8fd0c896ba749a88278572c9e62557770cebee01ab757286845416992259c
3
+ metadata.gz: 520355bc0ee6977875d0cf7673e2154ee8d09287b0b26b7a2311b6ead59a849b
4
+ data.tar.gz: 6dff21b60ac7ee50ae8aaa493b064413af17e0ec40088f555ffc518f82b53bba
5
5
  SHA512:
6
- metadata.gz: bf3b9b8d0ba55fceef78eaf2247efbe753de30b6d3e3a1a946105b3e848d517853ed0b58f4a65ee2caa9eaa1cae4919fb0eb4d021c1ac76bceb29983d1f658b9
7
- data.tar.gz: 6c69233b3e52f5022f96c45a06ade7e9402f2d0c2a59fbc3268a2a96804ecc1ef129cbc2313d663b690d309c91d19726fa03c25d3960e242fbceaa14fb660287
6
+ metadata.gz: f37353c25acf1d2212075c485456bc1115dff187a80189fe552e02890fd07887e471aae4ccdfbc4c9b448f1e0a224f60f34cda5f273ad5bed328c6c77a18e527
7
+ data.tar.gz: 5ad4a97670c4416dbd85f268a20c37bb02aa16278f408a20d3878913ce79bd0ea12602a874ab1d4a2db53d8da1984f8712d00420e2d69f558b0264decfadb88a
@@ -1,8 +1,14 @@
1
- # master [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.1.0...master)
1
+ # master [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.2.0...master)
2
2
 
3
- *
3
+ # v4.2.0 / 2019-10-22 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.1.0...v4.2.0)
4
4
 
5
- # master [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.0.2...v4.1.0)
5
+ * [BUGFIX] Fix CSS alignment of columns for when --suppress-ratings is used on the code page (by [@jbampton][])
6
+ * [BUGFIX] Fix typo in example `.rubycritic.yml` (by [@Adre][])
7
+ * [BUGFIX] Fix YAML configuration file 'formats' processing (by [@cvoltz][])
8
+ * [FEATURE] Add Markdown linting to the Travis build by using the Rubygem `markdownlint` (by [@jbampton][])
9
+ * [FEATURE] Add new report for SimpleCov (by [@etagwerker][])
10
+
11
+ # v4.1.0 / 2019-06-07 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.0.2...v4.1.0)
6
12
 
7
13
  * [BUGFIX] Assorted fixes in HTML report (by [@jbampton][])
8
14
  * [BUGFIX] Fix duplicate HTML5 DOCTYPE (by [@jbampton][])
@@ -15,7 +21,7 @@
15
21
 
16
22
  # 4.0.1 / 2019-03-12 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.0.0...v4.0.1)
17
23
 
18
- * [FEATUE] Allow passing formatters from the outside (by [@marcgrimme][] and [@onumis][])
24
+ * [FEATURE] Allow passing formatters from the outside (by [@marcgrimme][] and [@onumis][])
19
25
  * [CHANGE] Fix aruba deprecation warning
20
26
 
21
27
  # 4.0.0 / 2019-02-27 [(commits)](https://github.com/whitesmith/rubycritic/compare/v3.5.1...v4.0.0)
@@ -244,7 +250,6 @@
244
250
 
245
251
  * Official Release
246
252
 
247
-
248
253
  [@LeeXGreen]: https://github.com/LeeXGreen
249
254
  [@crackofdusk]: https://github.com/crackofdusk
250
255
  [@halostatue]: https://github.com/halostatue
@@ -289,3 +294,6 @@
289
294
  [@jbampton]: https://github.com/jbampton
290
295
  [@nathanbwright]: https://github.com/nathanbwright
291
296
  [@leksster]: https://github.com/leksster
297
+ [@etagwerker]: https://github.com/etagwerker
298
+ [@cvoltz]: https://github.com/cvoltz
299
+ [@Adre]: https://github.com/Adre
@@ -75,6 +75,7 @@ If you are experiencing unexpected behavior and, after having read the documenta
75
75
 
76
76
  Changelog entry format
77
77
  ------------------------
78
+
78
79
  Here are a few examples:
79
80
 
80
81
  ```
data/README.md CHANGED
@@ -1,15 +1,14 @@
1
- RubyCritic
2
- ==========
1
+ # RubyCritic
3
2
 
4
3
  [![Gem Version](https://badge.fury.io/rb/rubycritic.svg)](http://badge.fury.io/rb/rubycritic)
5
4
  [![Build Status](https://travis-ci.org/whitesmith/rubycritic.svg?branch=master)](https://travis-ci.org/whitesmith/rubycritic)
6
5
  [![Code Climate](https://codeclimate.com/github/whitesmith/rubycritic/badges/gpa.svg)](https://codeclimate.com/github/whitesmith/rubycritic)
7
6
 
8
- <img src="https://github.com/whitesmith/rubycritic/raw/master/images/logo.png" alt="RubyCritic Icon" align="right" />
7
+ <img src="https://github.com/whitesmith/rubycritic/raw/master/images/logo.png" alt="RubyCritic Icon" align="right">
9
8
 
10
9
  RubyCritic is a gem that wraps around static analysis gems such as [Reek][1], [Flay][2] and [Flog][3] to provide a quality report of your Ruby code.
11
10
 
12
- **Table of Contents**
11
+ ## Table of Contents
13
12
 
14
13
  - [Overview](#overview)
15
14
  - [Getting Started](#getting-started)
@@ -22,7 +21,6 @@ RubyCritic is a gem that wraps around static analysis gems such as [Reek][1], [F
22
21
  - [Contributors](#contributors)
23
22
  - [Credits](#credits)
24
23
 
25
-
26
24
  ## Overview
27
25
 
28
26
  This gem provides features such as:
@@ -68,7 +66,6 @@ This gem provides features such as:
68
66
 
69
67
  Checkout the `/docs` if you want to read more about our [core metrics](https://github.com/whitesmith/rubycritic/blob/master/docs/core-metrics.md).
70
68
 
71
-
72
69
  ## Getting Started
73
70
 
74
71
  RubyCritic can be installed with the following command:
@@ -90,7 +87,6 @@ And then execute:
90
87
  $ bundle
91
88
  ```
92
89
 
93
-
94
90
  ## Usage
95
91
 
96
92
  Running `rubycritic` with no arguments will analyse all the Ruby files in the
@@ -138,17 +134,19 @@ $ rubycritic --help
138
134
  You also can use a config file. Just create a `.rubycritic.yml` on your project root path.
139
135
 
140
136
  Here are one example:
137
+
141
138
  ```yml
142
139
  mode_ci:
143
140
  enabled: true # default is false
144
141
  branch: 'production' # default is master
145
142
  branch: 'production' # default is master
146
143
  path: '/tmp/mycustompath' # Set path where report will be saved (tmp/rubycritic by default)
147
- threshhold_score: 10 # default is 0
144
+ threshold_score: 10 # default is 0
148
145
  deduplicate_symlinks: true # default is false
149
146
  suppress_ratings: true # default is false
150
147
  no_browser: true # default is false
151
- format: console # Available values are: html, json, console, lint. Default value is html.
148
+ formats: # Available values are: html, json, console, lint. Default value is html.
149
+ - console
152
150
  minimum_score: 95 # default is 0
153
151
  paths: # Files to analyse.
154
152
  - 'app/controllers/'
@@ -162,10 +160,9 @@ paths: # Files to analyse.
162
160
  project root and `RubyCritic` will respect this configuration.
163
161
  * [`flay`](https://github.com/seattlerb/flay): We use `flay`'s default configuration.
164
162
  * [`flog`](https://github.com/seattlerb/flog): We use `flog`'s default configuration with a couple of [smaller tweaks](https://github.com/whitesmith/rubycritic/blob/master/lib/rubycritic/analysers/helpers/flog.rb#L5):
165
- * `all`: Forces `flog` to report scores on all classes and methods. Without this option `flog` will only give results up to a certain threshold.
166
- * `continue`: Makes it so that `flog` does not abort when a ruby file cannot be parsed.
167
- * `methods`: Configures `flog` to skip code outside of methods. It prevents `flog` from reporting on the "methods" `private` and `protected`. It also prevents `flog` from reporting on Rails methods like `before_action` and `has_many`.
168
-
163
+ * `all`: Forces `flog` to report scores on all classes and methods. Without this option `flog` will only give results up to a certain threshold.
164
+ * `continue`: Makes it so that `flog` does not abort when a ruby file cannot be parsed.
165
+ * `methods`: Configures `flog` to skip code outside of methods. It prevents `flog` from reporting on the "methods" `private` and `protected`. It also prevents `flog` from reporting on Rails methods like `before_action` and `has_many`.
169
166
 
170
167
  ### Alternative Usage Methods
171
168
 
@@ -173,7 +170,6 @@ If you're fond of Guard you might like [guard-rubycritic][4]. It automatically a
173
170
 
174
171
  For continuous integration, you can give [Jenkins CI][5] a spin. With it, you can [easily build your own (poor-man's) Code Climate][6]!
175
172
 
176
-
177
173
  ### Rake Task
178
174
 
179
175
  You can use RubyCritic as Rake command in its most simple form like this:
@@ -225,7 +221,6 @@ RubyCritic is supporting Ruby versions:
225
221
  * 2.5
226
222
  * 2.6
227
223
 
228
-
229
224
  ## Improving RubyCritic
230
225
 
231
226
  RubyCritic doesn't have to remain a second choice to other code quality analysis services. Together, we can improve it and continue to build on the great code metric tools that are available in the Ruby ecosystem.
@@ -236,10 +231,8 @@ Similarly, Pull Requests that improve the look and feel of the gem, that tweak t
236
231
 
237
232
  See RubyCritic's [contributing guidelines](https://github.com/whitesmith/rubycritic/blob/master/CONTRIBUTING.md) about how to proceed.
238
233
 
239
-
240
234
  ## Contributors
241
235
 
242
-
243
236
  `RubyCritics` initial author was [Guilherme Simões](https://github.com/guilhermesimoes).
244
237
 
245
238
  The current core team consists of:
@@ -248,7 +241,6 @@ The current core team consists of:
248
241
  * [Lucas Mazza](https://github.com/lucasmazza)
249
242
  * [Timo Rößner](https://github.com/troessner)
250
243
 
251
-
252
244
  ## Credits
253
245
 
254
246
  ![Whitesmith](https://github.com/whitesmith/rubycritic/raw/master/images/whitesmith.png)
data/ROADMAP.md CHANGED
@@ -39,7 +39,7 @@ These are more nice-to-haves than promises. We can always dream. But this is wha
39
39
 
40
40
  - [ ] [Brakeman](https://github.com/presidentbeef/brakeman) to provide security issues (Rails-only feature)
41
41
 
42
- - [ ] [Rails Best Practices](https://github.com/railsbp/rails_best_practices) to provide Rails smells (Rails-only feature) #14
42
+ - [ ] [Rails Best Practices](https://github.com/railsbp/rails_best_practices) to provide Rails smells (Rails-only feature) #14
43
43
 
44
44
  - [ ] [SandiMeter](https://github.com/makaroni4/sandi_meter) #15
45
45
 
@@ -53,4 +53,4 @@ These are more nice-to-haves than promises. We can always dream. But this is wha
53
53
 
54
54
  ![Code Climate Toggle Option](https://camo.githubusercontent.com/d97fc62dae6ebef1f35bda91942d4a6bacc445b2/687474703a2f2f626c6f672e636f6465636c696d6174652e636f6d2f696d616765732f706f7374732f74657374696e672e676966)
55
55
 
56
- Having an option to toggle between "Smells", "Security" (Brakeman) and "Style" (Rubocop) would be great. But that's already assuming we can integrate those gems into RubyCritic.
56
+ Having an option to toggle between "Smells", "Security" (Brakeman) and "Style" (Rubocop) would be great. But that's already assuming we can integrate those gems into RubyCritic.
@@ -0,0 +1,118 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubycritic/colorize'
4
+ require 'json'
5
+ require 'simplecov'
6
+
7
+ module RubyCritic
8
+ module Analyser
9
+ class Coverage
10
+ include Colorize
11
+
12
+ def initialize(analysed_modules)
13
+ @analysed_modules = analysed_modules
14
+ @result = results.first
15
+ end
16
+
17
+ def run
18
+ @analysed_modules.each do |analysed_module|
19
+ analysed_module.coverage = find_coverage_percentage(analysed_module)
20
+ print green '.'
21
+ end
22
+ puts ''
23
+ end
24
+
25
+ def to_s
26
+ 'simple_cov'
27
+ end
28
+
29
+ private
30
+
31
+ def find_coverage_percentage(analysed_module)
32
+ source_file = find_source_file(analysed_module)
33
+
34
+ return 0 unless source_file
35
+
36
+ source_file.covered_percent
37
+ end
38
+
39
+ def find_source_file(analysed_module)
40
+ return unless @result
41
+
42
+ needle = File.join(SimpleCov.root, analysed_module.path)
43
+
44
+ @result.source_files.detect { |file| file.filename == needle }
45
+ end
46
+
47
+ # The path to the .resultset.json cache file
48
+ def resultset_path
49
+ File.join(SimpleCov.coverage_path, '.resultset.json')
50
+ end
51
+
52
+ def resultset_writelock
53
+ File.join(SimpleCov.coverage_path, '.resultset.json.lock')
54
+ end
55
+
56
+ # Loads the cached resultset from JSON and returns it as a Hash,
57
+ # caching it for subsequent accesses.
58
+ def resultset
59
+ @resultset ||= begin
60
+ if (data = stored_data)
61
+ begin
62
+ JSON.parse(data) || {}
63
+ rescue JSON::ParserError => err
64
+ puts "Error: Loading .resultset.json: #{err.message}"
65
+ {}
66
+ end
67
+ else
68
+ {}
69
+ end
70
+ end
71
+ end
72
+
73
+ # Returns the contents of the resultset cache as a string or if the file is missing or empty nil
74
+ def stored_data
75
+ synchronize_resultset do
76
+ return unless File.exist?(resultset_path)
77
+
78
+ return unless (data = File.read(resultset_path))
79
+
80
+ return if data.length < 2
81
+
82
+ data
83
+ end
84
+ end
85
+
86
+ # Ensure only one process is reading or writing the resultset at any
87
+ # given time
88
+ def synchronize_resultset
89
+ # make it reentrant
90
+ return yield if defined?(@resultset_locked) && @resultset_locked == true
91
+
92
+ return yield unless File.exist?(resultset_writelock)
93
+
94
+ begin
95
+ @resultset_locked = true
96
+ File.open(resultset_writelock, 'w+') do |file|
97
+ file.flock(File::LOCK_EX)
98
+ yield
99
+ end
100
+ ensure
101
+ @resultset_locked = false
102
+ end
103
+ end
104
+
105
+ # Gets the resultset hash and re-creates all included instances
106
+ # of SimpleCov::Result from that.
107
+ # All results that are above the SimpleCov.merge_timeout will be
108
+ # dropped. Returns an array of SimpleCov::Result items.
109
+ def results
110
+ array = []
111
+ resultset.each do |command_name, data|
112
+ array << ::SimpleCov::Result.from_hash(command_name => data)
113
+ end
114
+ array
115
+ end
116
+ end
117
+ end
118
+ end
@@ -7,6 +7,7 @@ require 'rubycritic/analysers/smells/reek'
7
7
  require 'rubycritic/analysers/complexity'
8
8
  require 'rubycritic/analysers/churn'
9
9
  require 'rubycritic/analysers/attributes'
10
+ require 'rubycritic/analysers/coverage'
10
11
 
11
12
  module RubyCritic
12
13
  class AnalysersRunner
@@ -16,7 +17,8 @@ module RubyCritic
16
17
  Analyser::ReekSmells,
17
18
  Analyser::Complexity,
18
19
  Analyser::Attributes,
19
- Analyser::Churn
20
+ Analyser::Churn,
21
+ Analyser::Coverage
20
22
  ].freeze
21
23
 
22
24
  def initialize(paths)
@@ -25,7 +25,7 @@ module RubyCritic
25
25
  argv_hash = argv_options.to_h
26
26
 
27
27
  file_hash.merge(argv_hash) do |_, file_option, argv_option|
28
- argv_option.nil? ? file_option : argv_option
28
+ Array(argv_option).empty? ? file_option : argv_option
29
29
  end
30
30
  end
31
31
  end
@@ -76,10 +76,10 @@ module RubyCritic
76
76
  end
77
77
 
78
78
  def formats
79
- formats = options['formats'] || []
79
+ formats = Array(options['formats'])
80
80
  formats.select do |format|
81
81
  %w[html json console lint].include?(format)
82
- end
82
+ end.map(&:to_sym)
83
83
  end
84
84
 
85
85
  def minimum_score
@@ -10,6 +10,7 @@ module RubyCritic
10
10
  # Complexity is reduced by a factor of 25 when calculating cost
11
11
  COMPLEXITY_FACTOR = 25.0
12
12
 
13
+ attribute :coverage
13
14
  attribute :name
14
15
  attribute :smells_count
15
16
  attribute :file_location
@@ -44,6 +45,10 @@ module RubyCritic
44
45
  (complexity / COMPLEXITY_FACTOR)
45
46
  end
46
47
 
48
+ def coverage_rating
49
+ @coverage_rating ||= Rating.from_cost(100 - coverage)
50
+ end
51
+
47
52
  def rating
48
53
  @rating ||= Rating.from_cost(cost)
49
54
  end
@@ -74,15 +79,9 @@ module RubyCritic
74
79
 
75
80
  def to_h
76
81
  {
77
- name: name,
78
- path: path,
79
- smells: smells,
80
- churn: churn,
81
- committed_at: committed_at,
82
- complexity: complexity,
83
- duplication: duplication,
84
- methods_count: methods_count,
85
- cost: cost,
82
+ name: name, path: path, smells: smells,
83
+ churn: churn, committed_at: committed_at, complexity: complexity,
84
+ duplication: duplication, methods_count: methods_count, cost: cost,
86
85
  rating: rating
87
86
  }
88
87
  end
@@ -12,6 +12,9 @@ $(function() {
12
12
  else if(/smells_index/.test(loc)) {
13
13
  $('.smells-index-nav').addClass('active');
14
14
  }
15
+ else if(/simple_cov_index/.test(loc)) {
16
+ $('.coverage-index-nav').addClass('active');
17
+ }
15
18
  });
16
19
 
17
20
  var turbulenceData = turbulenceData || [];
@@ -208,19 +211,29 @@ function highlightLine(lineReference) {
208
211
 
209
212
  $("#toggle-code").on("click", showCode);
210
213
  $("#toggle-smells").on("click", showSmells);
214
+ $("#toggle-coverage").on("click", showCoverage);
211
215
 
212
216
  function showCode() {
213
217
  $('#toggle-code').parent('li').addClass('active');
214
218
  $('#toggle-smells').parent('li').removeClass('active');
219
+ $('#toggle-coverage').parent('li').removeClass('active');
215
220
  $(".smells").hide();
216
221
  }
217
222
 
218
223
  function showSmells() {
219
224
  $('#toggle-code').parent('li').removeClass('active');
225
+ $('#toggle-coverage').parent('li').removeClass('active');
220
226
  $('#toggle-smells').parent('li').addClass('active');
221
227
  $(".smells").show();
222
228
  }
223
229
 
230
+ function showCoverage() {
231
+ $('#toggle-code').parent('li').removeClass('active');
232
+ $('#toggle-smells').parent('li').removeClass('active');
233
+ $('#toggle-coverage').parent('li').addClass('active');
234
+ $(".coverage").show();
235
+ }
236
+
224
237
  $("#codeTable")
225
238
  .tablesorter({ // Sort the table
226
239
  sortList: [[0,1]]
@@ -277,10 +277,10 @@ header {
277
277
  color: #4e4d4d;
278
278
  font-weight: bold;
279
279
  }
280
- .table.code th:nth-child(1) {
280
+ .table.code th.center {
281
281
  text-align: center;
282
282
  }
283
- .table.code th:nth-child(2) {
283
+ .table.code th.left {
284
284
  text-align: left;
285
285
  }
286
286
  .table.code th {
@@ -291,10 +291,10 @@ header {
291
291
  .table td {
292
292
  color: #777575;
293
293
  }
294
- .table.code td:nth-child(1) {
294
+ .table.code td.center {
295
295
  text-align: center;
296
296
  }
297
- .table.code td:nth-child(2) {
297
+ .table.code td.left {
298
298
  text-align: left;
299
299
  }
300
300
  .table.code td {
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubycritic/generators/html/base'
4
+
5
+ module RubyCritic
6
+ module Generator
7
+ module Html
8
+ class SimpleCovIndex < Base
9
+ TEMPLATE = erb_template('simple_cov_index.html.erb')
10
+
11
+ def initialize(analysed_modules)
12
+ @analysed_modules = sorted(filtered(analysed_modules))
13
+ set_header_links if Config.compare_branches_mode?
14
+ end
15
+
16
+ def set_header_links
17
+ @base_path = code_index_path(Config.base_root_directory, file_name)
18
+ @feature_path = code_index_path(Config.feature_root_directory, file_name)
19
+ @build_path = code_index_path(Config.compare_root_directory, file_name)
20
+ end
21
+
22
+ def file_name
23
+ 'simple_cov_index.html'
24
+ end
25
+
26
+ def render
27
+ index_body = TEMPLATE.result(base_binding)
28
+ LAYOUT_TEMPLATE.result(base_binding { index_body })
29
+ end
30
+
31
+ def sorted(mods)
32
+ mods.sort_by(&:coverage)
33
+ end
34
+
35
+ def filtered(mods)
36
+ mods.reject do |a_module|
37
+ path = a_module.pathname.to_s
38
+ path.start_with?('spec', 'test')
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -9,9 +9,9 @@
9
9
  <thead>
10
10
  <tr>
11
11
  <% unless Config.suppress_ratings %>
12
- <th width="10%" class="table-header">Rating<span class="sort-type"></span></th>
12
+ <th width="10%" class="table-header center">Rating<span class="sort-type"></span></th>
13
13
  <% end %>
14
- <th width="50%" class="table-header">Name<span class="sort-type"></span></th>
14
+ <th width="50%" class="table-header left">Name<span class="sort-type"></span></th>
15
15
  <th width="10%" class="table-header">Churn<span class="sort-type"></span></th>
16
16
  <th width="10%" class="table-header">Complexity<span class="sort-type"></span></th>
17
17
  <th width="10%" class="table-header">Duplication<span class="sort-type"></span></th>
@@ -22,7 +22,7 @@
22
22
  <% @analysed_modules.each do |analysed_module| %>
23
23
  <tr>
24
24
  <% unless Config.suppress_ratings %>
25
- <td>
25
+ <td class="center">
26
26
  <% if Config.build_mode? %>
27
27
  <% master_analysed_module = Config.base_branch_collection.find(analysed_module.pathname) %>
28
28
  <% if master_analysed_module.cost > analysed_module.cost %>
@@ -36,7 +36,7 @@
36
36
  <div class="rating <%= analysed_module.rating.to_s.downcase %>"><%= analysed_module.rating %></div>
37
37
  </td>
38
38
  <% end %>
39
- <td>
39
+ <td class="left">
40
40
  <ul class="nav nav-pills">
41
41
  <li role="presentation" >
42
42
  <a href="<%= file_path(analysed_module.pathname.sub_ext('.html')) %>"><%= analysed_module.name %></a>
@@ -39,6 +39,9 @@
39
39
  <li class="sidebar-item">
40
40
  <a href="<%= file_path('smells_index.html') %>" class="project-nav-item smells-index-nav"><i class="fa fa-warning"></i>Smells</a>
41
41
  </li>
42
+ <li class="sidebar-item">
43
+ <a href="<%= file_path('simple_cov_index.html') %>" class="project-nav-item coverage-index-nav"><i class="fa fa-umbrella"></i>Coverage</a>
44
+ </li>
42
45
  </ul>
43
46
  </aside>
44
47
  <!-- /#sidebar-wrapper -->
@@ -0,0 +1,44 @@
1
+ <!-- Page Content -->
2
+ <div id="page-content-wrapper">
3
+ <div class="container-fluid">
4
+ <div class="row">
5
+ <!--Page Title -->
6
+ <div class="Page_Title">
7
+ <h3>Coverage</h3>
8
+ </div>
9
+ <!--End Page Title -->
10
+ <div class="Content_Wrapper">
11
+ <table id="js-index-table" class="table coverage-index-table index-table sortable-table">
12
+ <thead>
13
+ <tr>
14
+ <% unless Config.suppress_ratings %>
15
+ <th width="10%" class="table-header">Rating<span class="sort-type"></span></th>
16
+ <% end %>
17
+ <th width="80%" class="table-header">Name<span class="sort-type"></span></th>
18
+ <th width="10%" class="table-header">Coverage<span class="sort-type"></span></th>
19
+ </tr>
20
+ </thead>
21
+ <% @analysed_modules.each do |analysed_module| %>
22
+ <tr>
23
+ <tr>
24
+ <% unless Config.suppress_ratings %>
25
+ <td>
26
+ <div class="rating <%= analysed_module.rating.to_s.downcase %>"><%= analysed_module.coverage_rating %></div>
27
+ </td>
28
+ <% end %>
29
+ <td>
30
+ <ul class="nav nav-pills">
31
+ <li role="presentation" >
32
+ <a href="<%= file_path(analysed_module.pathname.sub_ext('.html')) %>"><%= analysed_module.name %></a>
33
+ </li>
34
+ </ul>
35
+ </td>
36
+ <td><%= '%g' % analysed_module.coverage %>%</td>
37
+ </tr>
38
+ <% end %>
39
+ </table>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ <!-- /#page-content-wrapper -->
@@ -5,6 +5,7 @@ require 'rubycritic/configuration'
5
5
  require 'rubycritic/generators/html/overview'
6
6
  require 'rubycritic/generators/html/smells_index'
7
7
  require 'rubycritic/generators/html/code_index'
8
+ require 'rubycritic/generators/html/simple_cov_index'
8
9
  require 'rubycritic/generators/html/code_file'
9
10
 
10
11
  module RubyCritic
@@ -39,7 +40,7 @@ module RubyCritic
39
40
  end
40
41
 
41
42
  def generators
42
- [overview_generator, code_index_generator, smells_index_generator] + file_generators
43
+ [overview_generator, code_index_generator, smells_index_generator, simple_cov_index_generator] + file_generators
43
44
  end
44
45
 
45
46
  def overview_generator
@@ -54,6 +55,10 @@ module RubyCritic
54
55
  Html::SmellsIndex.new(@analysed_modules)
55
56
  end
56
57
 
58
+ def simple_cov_index_generator
59
+ Html::SimpleCovIndex.new(@analysed_modules)
60
+ end
61
+
57
62
  def file_generators
58
63
  @analysed_modules.map do |analysed_module|
59
64
  Html::CodeFile.new(analysed_module)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyCritic
4
- VERSION = '4.1.0'.freeze
4
+ VERSION = '4.2.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubycritic
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Simoes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2019-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flay
@@ -114,6 +114,20 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '3.8'
117
+ - !ruby/object:Gem::Dependency
118
+ name: simplecov
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 0.17.0
124
+ type: :runtime
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 0.17.0
117
131
  - !ruby/object:Gem::Dependency
118
132
  name: tty-which
119
133
  requirement: !ruby/object:Gem::Requirement
@@ -256,6 +270,20 @@ dependencies:
256
270
  - - "~>"
257
271
  - !ruby/object:Gem::Version
258
272
  version: '0.10'
273
+ - !ruby/object:Gem::Dependency
274
+ name: mdl
275
+ requirement: !ruby/object:Gem::Requirement
276
+ requirements:
277
+ - - "~>"
278
+ - !ruby/object:Gem::Version
279
+ version: 0.5.0
280
+ type: :development
281
+ prerelease: false
282
+ version_requirements: !ruby/object:Gem::Requirement
283
+ requirements:
284
+ - - "~>"
285
+ - !ruby/object:Gem::Version
286
+ version: 0.5.0
259
287
  - !ruby/object:Gem::Dependency
260
288
  name: minitest
261
289
  requirement: !ruby/object:Gem::Requirement
@@ -371,6 +399,7 @@ files:
371
399
  - lib/rubycritic/analysers/attributes.rb
372
400
  - lib/rubycritic/analysers/churn.rb
373
401
  - lib/rubycritic/analysers/complexity.rb
402
+ - lib/rubycritic/analysers/coverage.rb
374
403
  - lib/rubycritic/analysers/helpers/ast_node.rb
375
404
  - lib/rubycritic/analysers/helpers/flay.rb
376
405
  - lib/rubycritic/analysers/helpers/flog.rb
@@ -439,12 +468,14 @@ files:
439
468
  - lib/rubycritic/generators/html/code_index.rb
440
469
  - lib/rubycritic/generators/html/line.rb
441
470
  - lib/rubycritic/generators/html/overview.rb
471
+ - lib/rubycritic/generators/html/simple_cov_index.rb
442
472
  - lib/rubycritic/generators/html/smells_index.rb
443
473
  - lib/rubycritic/generators/html/templates/code_file.html.erb
444
474
  - lib/rubycritic/generators/html/templates/code_index.html.erb
445
475
  - lib/rubycritic/generators/html/templates/layouts/application.html.erb
446
476
  - lib/rubycritic/generators/html/templates/line.html.erb
447
477
  - lib/rubycritic/generators/html/templates/overview.html.erb
478
+ - lib/rubycritic/generators/html/templates/simple_cov_index.html.erb
448
479
  - lib/rubycritic/generators/html/templates/smells_index.html.erb
449
480
  - lib/rubycritic/generators/html/templates/smelly_line.html.erb
450
481
  - lib/rubycritic/generators/html/turbulence.rb