rubycritic 2.9.3 → 2.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/bin/rubycritic +1 -0
- data/features/step_definitions/rake_task_steps.rb +1 -0
- data/features/step_definitions/rubycritic_steps.rb +1 -0
- data/features/step_definitions/sample_file_steps.rb +1 -0
- data/features/support/env.rb +1 -0
- data/lib/rubycritic.rb +1 -0
- data/lib/rubycritic/analysers/attributes.rb +1 -0
- data/lib/rubycritic/analysers/churn.rb +1 -0
- data/lib/rubycritic/analysers/complexity.rb +1 -0
- data/lib/rubycritic/analysers/helpers/ast_node.rb +1 -0
- data/lib/rubycritic/analysers/helpers/flay.rb +1 -0
- data/lib/rubycritic/analysers/helpers/flog.rb +1 -0
- data/lib/rubycritic/analysers/helpers/methods_counter.rb +1 -0
- data/lib/rubycritic/analysers/helpers/modules_locator.rb +1 -0
- data/lib/rubycritic/analysers/helpers/parser.rb +1 -0
- data/lib/rubycritic/analysers/helpers/reek.rb +1 -0
- data/lib/rubycritic/analysers/smells/flay.rb +1 -0
- data/lib/rubycritic/analysers/smells/flog.rb +1 -0
- data/lib/rubycritic/analysers/smells/reek.rb +1 -0
- data/lib/rubycritic/analysers_runner.rb +1 -0
- data/lib/rubycritic/browser.rb +1 -0
- data/lib/rubycritic/cli/application.rb +1 -0
- data/lib/rubycritic/cli/options.rb +21 -18
- data/lib/rubycritic/colorize.rb +1 -0
- data/lib/rubycritic/command_factory.rb +1 -0
- data/lib/rubycritic/commands/base.rb +1 -0
- data/lib/rubycritic/commands/ci.rb +6 -1
- data/lib/rubycritic/commands/default.rb +9 -4
- data/lib/rubycritic/commands/help.rb +7 -2
- data/lib/rubycritic/commands/status_reporter.rb +7 -6
- data/lib/rubycritic/commands/version.rb +3 -1
- data/lib/rubycritic/configuration.rb +1 -0
- data/lib/rubycritic/core/analysed_module.rb +1 -0
- data/lib/rubycritic/core/analysed_modules_collection.rb +1 -0
- data/lib/rubycritic/core/location.rb +1 -0
- data/lib/rubycritic/core/rating.rb +1 -0
- data/lib/rubycritic/core/smell.rb +2 -1
- data/lib/rubycritic/generators/console_report.rb +1 -0
- data/lib/rubycritic/generators/html/base.rb +1 -0
- data/lib/rubycritic/generators/html/code_file.rb +3 -2
- data/lib/rubycritic/generators/html/code_index.rb +1 -0
- data/lib/rubycritic/generators/html/line.rb +1 -0
- data/lib/rubycritic/generators/html/overview.rb +1 -0
- data/lib/rubycritic/generators/html/smells_index.rb +1 -0
- data/lib/rubycritic/generators/html/turbulence.rb +1 -0
- data/lib/rubycritic/generators/html/view_helpers.rb +1 -0
- data/lib/rubycritic/generators/html_report.rb +1 -0
- data/lib/rubycritic/generators/json/simple.rb +1 -0
- data/lib/rubycritic/generators/json_report.rb +1 -0
- data/lib/rubycritic/generators/text/list.rb +1 -0
- data/lib/rubycritic/rake_task.rb +1 -0
- data/lib/rubycritic/reporter.rb +1 -0
- data/lib/rubycritic/serializer.rb +1 -0
- data/lib/rubycritic/smells_status_setter.rb +1 -0
- data/lib/rubycritic/source_control_systems/base.rb +1 -0
- data/lib/rubycritic/source_control_systems/double.rb +1 -0
- data/lib/rubycritic/source_control_systems/git.rb +1 -0
- data/lib/rubycritic/source_control_systems/mercurial.rb +1 -0
- data/lib/rubycritic/version.rb +1 -1
- data/rubycritic.gemspec +5 -4
- data/test/analysers_test_helper.rb +1 -0
- data/test/lib/rubycritic/analysers/churn_test.rb +1 -0
- data/test/lib/rubycritic/analysers/complexity_test.rb +1 -0
- data/test/lib/rubycritic/analysers/helpers/methods_counter_test.rb +1 -0
- data/test/lib/rubycritic/analysers/helpers/modules_locator_test.rb +1 -0
- data/test/lib/rubycritic/analysers/smells/flay_test.rb +1 -0
- data/test/lib/rubycritic/analysers/smells/flog_test.rb +1 -0
- data/test/lib/rubycritic/analysers/smells/reek_test.rb +1 -0
- data/test/lib/rubycritic/browser_test.rb +1 -0
- data/test/lib/rubycritic/commands/status_reporter_test.rb +1 -0
- data/test/lib/rubycritic/configuration_test.rb +1 -0
- data/test/lib/rubycritic/core/analysed_module_test.rb +1 -0
- data/test/lib/rubycritic/core/analysed_modules_collection_test.rb +1 -0
- data/test/lib/rubycritic/core/location_test.rb +1 -0
- data/test/lib/rubycritic/core/smell_test.rb +1 -0
- data/test/lib/rubycritic/core/smells_array_test.rb +1 -0
- data/test/lib/rubycritic/generators/console_report_test.rb +1 -0
- data/test/lib/rubycritic/generators/json_report_test.rb +1 -0
- data/test/lib/rubycritic/generators/turbulence_test.rb +1 -0
- data/test/lib/rubycritic/generators/view_helpers_test.rb +1 -0
- data/test/lib/rubycritic/revision_comparator_test.rb +1 -0
- data/test/lib/rubycritic/smells_status_setter_test.rb +1 -0
- data/test/lib/rubycritic/source_control_systems/base_test.rb +1 -0
- data/test/lib/rubycritic/source_control_systems/double_test.rb +1 -0
- data/test/lib/rubycritic/source_control_systems/git_test.rb +1 -0
- data/test/lib/rubycritic/source_control_systems/interfaces/basic.rb +1 -0
- data/test/lib/rubycritic/source_control_systems/interfaces/time_travel.rb +1 -0
- data/test/lib/rubycritic/source_control_systems/mercurial_test.rb +1 -0
- data/test/lib/rubycritic/source_locator_test.rb +1 -0
- data/test/lib/rubycritic/version_test.rb +1 -0
- data/test/test_helper.rb +1 -0
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec33a1c32385f0cbfdefeaa9129d913496b1ae5c
|
4
|
+
data.tar.gz: dee2aa84cf1b44b413d269c9f245376922a20519
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a5d63349c3a3cf426b70edfb3ffc5bf28a6c6d469fd4e725aed83633e7b6e0d3ccc7ab708c9fabaabb73afb4e7984b08b00885456f6c2bf1499248b84f3bbe5
|
7
|
+
data.tar.gz: afe13be04b5e8cf03258f08fb1cb82403a99e41afa092bdc26e57a4e254d850ee5e047a2739e0e48a1032b54c680c8061c260fcead134439308d067c034aa864
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/rubycritic
CHANGED
data/features/support/env.rb
CHANGED
data/lib/rubycritic.rb
CHANGED
data/lib/rubycritic/browser.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'optparse'
|
2
3
|
require 'rubycritic/browser'
|
3
4
|
|
@@ -6,12 +7,12 @@ module RubyCritic
|
|
6
7
|
class Options
|
7
8
|
def initialize(argv)
|
8
9
|
@argv = argv
|
9
|
-
|
10
|
+
self.parser = OptionParser.new
|
10
11
|
end
|
11
12
|
|
12
13
|
# rubocop:disable Metrics/MethodLength
|
13
14
|
def parse
|
14
|
-
|
15
|
+
parser.new do |opts|
|
15
16
|
opts.banner = 'Usage: rubycritic [options] [paths]'
|
16
17
|
|
17
18
|
opts.on('-p', '--path [PATH]', 'Set path where report will be saved (tmp/rubycritic by default)') do |path|
|
@@ -26,35 +27,35 @@ module RubyCritic
|
|
26
27
|
' json',
|
27
28
|
' console'
|
28
29
|
) do |format|
|
29
|
-
|
30
|
+
self.format = format
|
30
31
|
end
|
31
32
|
|
32
33
|
opts.on('-s', '--minimum-score [MIN_SCORE]', 'Set a minimum score') do |min_score|
|
33
|
-
|
34
|
+
self.minimum_score = Integer(min_score)
|
34
35
|
end
|
35
36
|
|
36
37
|
opts.on('-m', '--mode-ci', 'Use CI mode (faster, but only analyses last commit)') do
|
37
|
-
|
38
|
+
self.mode = :ci
|
38
39
|
end
|
39
40
|
|
40
41
|
opts.on('--deduplicate-symlinks', 'De-duplicate symlinks based on their final target') do
|
41
|
-
|
42
|
+
self.deduplicate_symlinks = true
|
42
43
|
end
|
43
44
|
|
44
45
|
opts.on('--suppress-ratings', 'Suppress letter ratings') do
|
45
|
-
|
46
|
+
self.suppress_ratings = true
|
46
47
|
end
|
47
48
|
|
48
49
|
opts.on('--no-browser', 'Do not open html report with browser') do
|
49
|
-
|
50
|
+
self.no_browser = true
|
50
51
|
end
|
51
52
|
|
52
53
|
opts.on_tail('-v', '--version', "Show gem's version") do
|
53
|
-
|
54
|
+
self.mode = :version
|
54
55
|
end
|
55
56
|
|
56
57
|
opts.on_tail('-h', '--help', 'Show this message') do
|
57
|
-
|
58
|
+
self.mode = :help
|
58
59
|
end
|
59
60
|
end.parse!(@argv)
|
60
61
|
self
|
@@ -62,20 +63,22 @@ module RubyCritic
|
|
62
63
|
|
63
64
|
def to_h
|
64
65
|
{
|
65
|
-
mode:
|
66
|
-
root:
|
67
|
-
format:
|
68
|
-
deduplicate_symlinks:
|
66
|
+
mode: mode,
|
67
|
+
root: root,
|
68
|
+
format: format,
|
69
|
+
deduplicate_symlinks: deduplicate_symlinks,
|
69
70
|
paths: paths,
|
70
|
-
suppress_ratings:
|
71
|
-
help_text:
|
72
|
-
minimum_score:
|
73
|
-
no_browser:
|
71
|
+
suppress_ratings: suppress_ratings,
|
72
|
+
help_text: parser.help,
|
73
|
+
minimum_score: minimum_score || 0,
|
74
|
+
no_browser: no_browser
|
74
75
|
}
|
75
76
|
end
|
76
77
|
|
77
78
|
private
|
78
79
|
|
80
|
+
attr_accessor :mode, :root, :format, :deduplicate_symlinks,
|
81
|
+
:suppress_ratings, :minimum_score, :no_browser, :parser
|
79
82
|
def paths
|
80
83
|
if @argv.empty?
|
81
84
|
['.']
|
data/lib/rubycritic/colorize.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rubycritic/source_control_systems/base'
|
2
3
|
require 'rubycritic/analysers_runner'
|
3
4
|
require 'rubycritic/reporter'
|
@@ -7,8 +8,12 @@ module RubyCritic
|
|
7
8
|
module Command
|
8
9
|
class Ci < Default
|
9
10
|
def critique
|
10
|
-
AnalysersRunner.new(
|
11
|
+
AnalysersRunner.new(paths).run
|
11
12
|
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
attr_reader :paths
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rubycritic/source_control_systems/base'
|
2
3
|
require 'rubycritic/analysers_runner'
|
3
4
|
require 'rubycritic/revision_comparator'
|
@@ -15,18 +16,22 @@ module RubyCritic
|
|
15
16
|
|
16
17
|
def execute
|
17
18
|
report(critique)
|
18
|
-
|
19
|
+
status_reporter
|
19
20
|
end
|
20
21
|
|
21
22
|
def critique
|
22
|
-
analysed_modules = AnalysersRunner.new(
|
23
|
-
RevisionComparator.new(
|
23
|
+
analysed_modules = AnalysersRunner.new(paths).run
|
24
|
+
RevisionComparator.new(paths).set_statuses(analysed_modules)
|
24
25
|
end
|
25
26
|
|
26
27
|
def report(analysed_modules)
|
27
28
|
Reporter.generate_report(analysed_modules)
|
28
|
-
|
29
|
+
status_reporter.score = analysed_modules.score
|
29
30
|
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :paths, :status_reporter
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
@@ -1,12 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rubycritic/commands/base'
|
2
3
|
|
3
4
|
module RubyCritic
|
4
5
|
module Command
|
5
6
|
class Help < Base
|
6
7
|
def execute
|
7
|
-
puts
|
8
|
-
|
8
|
+
puts options[:help_text]
|
9
|
+
status_reporter
|
9
10
|
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :options, :status_reporter
|
10
15
|
end
|
11
16
|
end
|
12
17
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module RubyCritic
|
2
3
|
module Command
|
3
4
|
class StatusReporter
|
4
|
-
attr_reader :status, :status_message
|
5
|
+
attr_reader :status, :status_message, :score
|
5
6
|
SUCCESS = 0
|
6
7
|
SCORE_BELOW_MINIMUM = 1
|
7
8
|
|
@@ -10,8 +11,8 @@ module RubyCritic
|
|
10
11
|
@status = SUCCESS
|
11
12
|
end
|
12
13
|
|
13
|
-
def score=(
|
14
|
-
@score =
|
14
|
+
def score=(input_score)
|
15
|
+
@score = input_score.round(2)
|
15
16
|
update_status
|
16
17
|
end
|
17
18
|
|
@@ -27,15 +28,15 @@ module RubyCritic
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def satisfy_minimum_score_rule
|
30
|
-
|
31
|
+
score >= @options[:minimum_score]
|
31
32
|
end
|
32
33
|
|
33
34
|
def update_status_message
|
34
35
|
case @status
|
35
36
|
when SUCCESS
|
36
|
-
@status_message = "Score: #{
|
37
|
+
@status_message = "Score: #{score}"
|
37
38
|
when SCORE_BELOW_MINIMUM
|
38
|
-
@status_message = "Score (#{
|
39
|
+
@status_message = "Score (#{score}) is below the minimum #{@options[:minimum_score]}"
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rubycritic/version'
|
2
3
|
require 'rubycritic/commands/base'
|
3
4
|
|
4
5
|
module RubyCritic
|
5
6
|
module Command
|
6
7
|
class Version < Base
|
8
|
+
attr_reader :status_reporter
|
7
9
|
def execute
|
8
10
|
puts "RubyCritic #{VERSION}"
|
9
|
-
|
11
|
+
status_reporter
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rubycritic/generators/html/base'
|
2
3
|
require 'rubycritic/generators/html/line'
|
3
4
|
|
@@ -22,14 +23,14 @@ module RubyCritic
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def render
|
25
|
-
file_code =
|
26
|
+
file_code = []
|
26
27
|
File.readlines(@pathname).each.with_index(LINE_NUMBER_OFFSET) do |line_text, line_number|
|
27
28
|
location = Location.new(@pathname, line_number)
|
28
29
|
line_smells = @analysed_module.smells_at_location(location)
|
29
30
|
file_code << Line.new(file_directory, line_text, line_smells).render
|
30
31
|
end
|
31
32
|
|
32
|
-
file_body = TEMPLATE.result(get_binding { file_code })
|
33
|
+
file_body = TEMPLATE.result(get_binding { file_code.join })
|
33
34
|
LAYOUT_TEMPLATE.result(get_binding { file_body })
|
34
35
|
end
|
35
36
|
end
|
data/lib/rubycritic/rake_task.rb
CHANGED
data/lib/rubycritic/reporter.rb
CHANGED
data/lib/rubycritic/version.rb
CHANGED
data/rubycritic.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'rubycritic/version'
|
@@ -21,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
21
22
|
spec.require_path = 'lib'
|
22
23
|
|
23
24
|
spec.add_runtime_dependency 'virtus', '~> 1.0'
|
24
|
-
spec.add_runtime_dependency 'flay', '2.8
|
25
|
-
spec.add_runtime_dependency 'flog', '4.4
|
26
|
-
spec.add_runtime_dependency 'reek', '4.
|
25
|
+
spec.add_runtime_dependency 'flay', '~> 2.8'
|
26
|
+
spec.add_runtime_dependency 'flog', '~> 4.4'
|
27
|
+
spec.add_runtime_dependency 'reek', '~> 4.4'
|
27
28
|
spec.add_runtime_dependency 'parser', '2.3.1.2'
|
28
29
|
spec.add_runtime_dependency 'ruby_parser', '~> 3.8'
|
29
30
|
spec.add_runtime_dependency 'colorize'
|
@@ -36,6 +37,6 @@ Gem::Specification.new do |spec|
|
|
36
37
|
spec.add_development_dependency 'rake'
|
37
38
|
spec.add_development_dependency 'minitest', '~> 5.3'
|
38
39
|
spec.add_development_dependency 'mocha', '~> 1.1'
|
39
|
-
spec.add_development_dependency 'rubocop', '>= 0.
|
40
|
+
spec.add_development_dependency 'rubocop', '>= 0.42.0'
|
40
41
|
spec.add_development_dependency 'pry-byebug'
|
41
42
|
end
|
data/test/test_helper.rb
CHANGED
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: 2.9.
|
4
|
+
version: 2.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Simoes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -28,44 +28,44 @@ dependencies:
|
|
28
28
|
name: flay
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.8
|
33
|
+
version: '2.8'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.8
|
40
|
+
version: '2.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: flog
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 4.4
|
47
|
+
version: '4.4'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 4.4
|
54
|
+
version: '4.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: reek
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 4.
|
61
|
+
version: '4.4'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 4.
|
68
|
+
version: '4.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: parser
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,14 +226,14 @@ dependencies:
|
|
226
226
|
requirements:
|
227
227
|
- - ">="
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version: 0.
|
229
|
+
version: 0.42.0
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
requirements:
|
234
234
|
- - ">="
|
235
235
|
- !ruby/object:Gem::Version
|
236
|
-
version: 0.
|
236
|
+
version: 0.42.0
|
237
237
|
- !ruby/object:Gem::Dependency
|
238
238
|
name: pry-byebug
|
239
239
|
requirement: !ruby/object:Gem::Requirement
|