rubycritic 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -4
- data/bin/rubycritic +2 -0
- data/lib/rubycritic/adapters/complexity/flog.rb +8 -6
- data/lib/rubycritic/adapters/smell/flay.rb +31 -9
- data/lib/rubycritic/adapters/smell/flog.rb +18 -9
- data/lib/rubycritic/adapters/smell/reek.rb +12 -5
- data/lib/rubycritic/analysers/churn.rb +6 -3
- data/lib/rubycritic/analysers/stats.rb +31 -0
- data/lib/rubycritic/analysers_runner.rb +13 -19
- data/lib/rubycritic/cli.rb +34 -18
- data/lib/rubycritic/configuration.rb +7 -1
- data/lib/rubycritic/core/analysed_file.rb +27 -1
- data/lib/rubycritic/core/location.rb +1 -1
- data/lib/rubycritic/core/rating.rb +22 -0
- data/lib/rubycritic/core/smell.rb +3 -12
- data/lib/rubycritic/files_initializer.rb +15 -0
- data/lib/rubycritic/orchestrator.rb +23 -0
- data/lib/rubycritic/report_generators/assets/javascripts/application.js +5 -3
- data/lib/rubycritic/report_generators/assets/javascripts/jquery.timeago-v1.4.1.js +214 -0
- data/lib/rubycritic/report_generators/assets/stylesheets/application.css +87 -2
- data/lib/rubycritic/report_generators/code_file.rb +1 -3
- data/lib/rubycritic/report_generators/code_index.rb +0 -1
- data/lib/rubycritic/report_generators/current_code_file.rb +17 -0
- data/lib/rubycritic/report_generators/line.rb +0 -1
- data/lib/rubycritic/report_generators/overview.rb +1 -2
- data/lib/rubycritic/report_generators/smells_index.rb +0 -1
- data/lib/rubycritic/report_generators/templates/code_file.html.erb +28 -1
- data/lib/rubycritic/report_generators/templates/code_index.html.erb +6 -2
- data/lib/rubycritic/report_generators/templates/layouts/application.html.erb +8 -7
- data/lib/rubycritic/report_generators/templates/overview.html.erb +1 -1
- data/lib/rubycritic/report_generators/view_helpers.rb +6 -2
- data/lib/rubycritic/reporters/main.rb +7 -3
- data/lib/rubycritic/reporters/mini.rb +13 -4
- data/lib/rubycritic/revision_comparator.rb +15 -16
- data/lib/rubycritic/serializer.rb +32 -0
- data/lib/rubycritic/smells_status_setter.rb +5 -11
- data/lib/rubycritic/source_control_systems/base.rb +60 -0
- data/lib/rubycritic/source_control_systems/double.rb +19 -0
- data/lib/rubycritic/source_control_systems/git.rb +46 -40
- data/lib/rubycritic/turbulence.rb +3 -7
- data/lib/rubycritic/version.rb +1 -1
- data/lib/rubycritic.rb +1 -7
- data/rubycritic.gemspec +1 -0
- data/test/lib/rubycritic/adapters/complexity/flog_test.rb +5 -5
- data/test/lib/rubycritic/adapters/smell/flay_test.rb +19 -8
- data/test/lib/rubycritic/adapters/smell/flog_test.rb +11 -8
- data/test/lib/rubycritic/adapters/smell/reek_test.rb +14 -10
- data/test/lib/rubycritic/analysers/churn_test.rb +23 -8
- data/test/lib/rubycritic/core/analysed_file_test.rb +31 -11
- data/test/lib/rubycritic/core/smell_test.rb +13 -20
- data/test/lib/rubycritic/smells_status_setter_test.rb +2 -2
- data/test/lib/rubycritic/source_control_systems/source_control_system_test.rb +5 -12
- data/test/lib/rubycritic/turbulence_test.rb +1 -2
- data/test/lib/rubycritic/version_test.rb +1 -0
- data/test/samples/flog/{smelly2.rb → complex.rb} +0 -0
- data/test/test_helper.rb +1 -0
- metadata +27 -17
- data/lib/rubycritic/active_support/methods.rb +0 -36
- data/lib/rubycritic/analysed_files_builder.rb +0 -36
- data/lib/rubycritic/orchestrators/base.rb +0 -27
- data/lib/rubycritic/orchestrators/main.rb +0 -14
- data/lib/rubycritic/orchestrators/mini.rb +0 -14
- data/lib/rubycritic/smells_serializer.rb +0 -32
- data/lib/rubycritic/source_control_systems/source_control_system.rb +0 -50
- data/test/lib/rubycritic/analysed_files_builder_test.rb +0 -36
- data/test/lib/rubycritic/analysers_runner_test.rb +0 -11
- data/test/samples/analysers_runner/empty.rb +0 -0
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: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Simoes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.3.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: code_analyzer
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.4.5
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.4.5
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,38 +154,39 @@ files:
|
|
140
154
|
- Rakefile
|
141
155
|
- bin/rubycritic
|
142
156
|
- lib/rubycritic.rb
|
143
|
-
- lib/rubycritic/active_support/methods.rb
|
144
157
|
- lib/rubycritic/adapters/complexity/flog.rb
|
145
158
|
- lib/rubycritic/adapters/smell/flay.rb
|
146
159
|
- lib/rubycritic/adapters/smell/flog.rb
|
147
160
|
- lib/rubycritic/adapters/smell/reek.rb
|
148
|
-
- lib/rubycritic/analysed_files_builder.rb
|
149
161
|
- lib/rubycritic/analysers/churn.rb
|
150
162
|
- lib/rubycritic/analysers/config.reek
|
151
163
|
- lib/rubycritic/analysers/flay.rb
|
152
164
|
- lib/rubycritic/analysers/flog.rb
|
153
165
|
- lib/rubycritic/analysers/reek.rb
|
166
|
+
- lib/rubycritic/analysers/stats.rb
|
154
167
|
- lib/rubycritic/analysers_runner.rb
|
155
168
|
- lib/rubycritic/cli.rb
|
156
169
|
- lib/rubycritic/configuration.rb
|
157
170
|
- lib/rubycritic/core/analysed_file.rb
|
158
171
|
- lib/rubycritic/core/location.rb
|
172
|
+
- lib/rubycritic/core/rating.rb
|
159
173
|
- lib/rubycritic/core/smell.rb
|
160
|
-
- lib/rubycritic/
|
161
|
-
- lib/rubycritic/
|
162
|
-
- lib/rubycritic/orchestrators/mini.rb
|
174
|
+
- lib/rubycritic/files_initializer.rb
|
175
|
+
- lib/rubycritic/orchestrator.rb
|
163
176
|
- lib/rubycritic/report_generators/assets/javascripts/application.js
|
164
177
|
- lib/rubycritic/report_generators/assets/javascripts/highcharts.src-4.0.1.js
|
165
178
|
- lib/rubycritic/report_generators/assets/javascripts/jquery-2.1.0.js
|
166
179
|
- lib/rubycritic/report_generators/assets/javascripts/jquery.floatThead-v1.2.7.js
|
167
180
|
- lib/rubycritic/report_generators/assets/javascripts/jquery.scrollTo-1.4.11.js
|
168
181
|
- lib/rubycritic/report_generators/assets/javascripts/jquery.tablesorter-2.0.js
|
182
|
+
- lib/rubycritic/report_generators/assets/javascripts/jquery.timeago-v1.4.1.js
|
169
183
|
- lib/rubycritic/report_generators/assets/javascripts/prettify-4-Mar-2013.js
|
170
184
|
- lib/rubycritic/report_generators/assets/stylesheets/application.css
|
171
185
|
- lib/rubycritic/report_generators/assets/stylesheets/prettify.custom_theme.css
|
172
186
|
- lib/rubycritic/report_generators/base.rb
|
173
187
|
- lib/rubycritic/report_generators/code_file.rb
|
174
188
|
- lib/rubycritic/report_generators/code_index.rb
|
189
|
+
- lib/rubycritic/report_generators/current_code_file.rb
|
175
190
|
- lib/rubycritic/report_generators/line.rb
|
176
191
|
- lib/rubycritic/report_generators/overview.rb
|
177
192
|
- lib/rubycritic/report_generators/smells_index.rb
|
@@ -187,10 +202,11 @@ files:
|
|
187
202
|
- lib/rubycritic/reporters/main.rb
|
188
203
|
- lib/rubycritic/reporters/mini.rb
|
189
204
|
- lib/rubycritic/revision_comparator.rb
|
190
|
-
- lib/rubycritic/
|
205
|
+
- lib/rubycritic/serializer.rb
|
191
206
|
- lib/rubycritic/smells_status_setter.rb
|
207
|
+
- lib/rubycritic/source_control_systems/base.rb
|
208
|
+
- lib/rubycritic/source_control_systems/double.rb
|
192
209
|
- lib/rubycritic/source_control_systems/git.rb
|
193
|
-
- lib/rubycritic/source_control_systems/source_control_system.rb
|
194
210
|
- lib/rubycritic/source_locator.rb
|
195
211
|
- lib/rubycritic/turbulence.rb
|
196
212
|
- lib/rubycritic/version.rb
|
@@ -199,9 +215,7 @@ files:
|
|
199
215
|
- test/lib/rubycritic/adapters/smell/flay_test.rb
|
200
216
|
- test/lib/rubycritic/adapters/smell/flog_test.rb
|
201
217
|
- test/lib/rubycritic/adapters/smell/reek_test.rb
|
202
|
-
- test/lib/rubycritic/analysed_files_builder_test.rb
|
203
218
|
- test/lib/rubycritic/analysers/churn_test.rb
|
204
|
-
- test/lib/rubycritic/analysers_runner_test.rb
|
205
219
|
- test/lib/rubycritic/configuration_test.rb
|
206
220
|
- test/lib/rubycritic/core/analysed_file_test.rb
|
207
221
|
- test/lib/rubycritic/core/location_test.rb
|
@@ -212,10 +226,9 @@ files:
|
|
212
226
|
- test/lib/rubycritic/source_locator_test.rb
|
213
227
|
- test/lib/rubycritic/turbulence_test.rb
|
214
228
|
- test/lib/rubycritic/version_test.rb
|
215
|
-
- test/samples/analysers_runner/empty.rb
|
216
229
|
- test/samples/flay/smelly.rb
|
230
|
+
- test/samples/flog/complex.rb
|
217
231
|
- test/samples/flog/smelly.rb
|
218
|
-
- test/samples/flog/smelly2.rb
|
219
232
|
- test/samples/location/dir1/file1.rb
|
220
233
|
- test/samples/location/file0.rb
|
221
234
|
- test/samples/location/file_with_different_extension.py
|
@@ -252,9 +265,7 @@ test_files:
|
|
252
265
|
- test/lib/rubycritic/adapters/smell/flay_test.rb
|
253
266
|
- test/lib/rubycritic/adapters/smell/flog_test.rb
|
254
267
|
- test/lib/rubycritic/adapters/smell/reek_test.rb
|
255
|
-
- test/lib/rubycritic/analysed_files_builder_test.rb
|
256
268
|
- test/lib/rubycritic/analysers/churn_test.rb
|
257
|
-
- test/lib/rubycritic/analysers_runner_test.rb
|
258
269
|
- test/lib/rubycritic/configuration_test.rb
|
259
270
|
- test/lib/rubycritic/core/analysed_file_test.rb
|
260
271
|
- test/lib/rubycritic/core/location_test.rb
|
@@ -265,10 +276,9 @@ test_files:
|
|
265
276
|
- test/lib/rubycritic/source_locator_test.rb
|
266
277
|
- test/lib/rubycritic/turbulence_test.rb
|
267
278
|
- test/lib/rubycritic/version_test.rb
|
268
|
-
- test/samples/analysers_runner/empty.rb
|
269
279
|
- test/samples/flay/smelly.rb
|
280
|
+
- test/samples/flog/complex.rb
|
270
281
|
- test/samples/flog/smelly.rb
|
271
|
-
- test/samples/flog/smelly2.rb
|
272
282
|
- test/samples/location/dir1/file1.rb
|
273
283
|
- test/samples/location/file0.rb
|
274
284
|
- test/samples/location/file_with_different_extension.py
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Rubycritic
|
2
|
-
|
3
|
-
module ActiveSupport
|
4
|
-
def constantize(camel_cased_word)
|
5
|
-
names = camel_cased_word.split('::')
|
6
|
-
|
7
|
-
# Trigger a built-in NameError exception including the ill-formed constant in the message.
|
8
|
-
Object.const_get(camel_cased_word) if names.empty?
|
9
|
-
|
10
|
-
# Remove the first blank element in case of '::ClassName' notation.
|
11
|
-
names.shift if names.size > 1 && names.first.empty?
|
12
|
-
|
13
|
-
names.inject(Object) do |constant, name|
|
14
|
-
if constant == Object
|
15
|
-
constant.const_get(name)
|
16
|
-
else
|
17
|
-
candidate = constant.const_get(name)
|
18
|
-
next candidate if constant.const_defined?(name, false)
|
19
|
-
next candidate unless Object.const_defined?(name)
|
20
|
-
|
21
|
-
# Go down the ancestors to check it it's owned
|
22
|
-
# directly before we reach Object or the end of ancestors.
|
23
|
-
constant = constant.ancestors.inject do |const, ancestor|
|
24
|
-
break const if ancestor == Object
|
25
|
-
break ancestor if ancestor.const_defined?(name, false)
|
26
|
-
const
|
27
|
-
end
|
28
|
-
|
29
|
-
# owner is in Object, so raise
|
30
|
-
constant.const_get(name, false)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "rubycritic/core/analysed_file"
|
2
|
-
|
3
|
-
module Rubycritic
|
4
|
-
|
5
|
-
class AnalysedFilesBuilder
|
6
|
-
def initialize(pathnames, smells, churn, complexity)
|
7
|
-
@pathnames = pathnames
|
8
|
-
@smells = smells
|
9
|
-
@churn = churn
|
10
|
-
@complexity = complexity
|
11
|
-
end
|
12
|
-
|
13
|
-
def analysed_files
|
14
|
-
@pathnames.zip(@churn, @complexity).map do |file_attributes|
|
15
|
-
pathname = file_attributes[0]
|
16
|
-
AnalysedFile.new(
|
17
|
-
:smells => file_smells(pathname),
|
18
|
-
:pathname => pathname,
|
19
|
-
:churn => file_attributes[1],
|
20
|
-
:complexity => file_attributes[2]
|
21
|
-
)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def file_smells(pathname)
|
28
|
-
file_smells = []
|
29
|
-
@smells.each do |smell|
|
30
|
-
file_smells << smell if smell.at_pathname?(pathname)
|
31
|
-
end
|
32
|
-
file_smells
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Rubycritic
|
2
|
-
module Orchestrator
|
3
|
-
|
4
|
-
class Base
|
5
|
-
def initialize
|
6
|
-
@source_control_system = SourceControlSystem.create
|
7
|
-
end
|
8
|
-
|
9
|
-
def critique(paths)
|
10
|
-
source = SourceLocator.new(paths)
|
11
|
-
@smells = AnalysersRunner.new(source.paths).smells
|
12
|
-
if @source_control_system.has_revision?
|
13
|
-
@smells = RevisionComparator.new(@smells, @source_control_system).smells
|
14
|
-
churn = Analyser::Churn.new(source.paths, @source_control_system).churn
|
15
|
-
end
|
16
|
-
complexity = ComplexityAdapter::Flog.new(source.paths).complexity
|
17
|
-
@analysed_files = AnalysedFilesBuilder.new(source.pathnames, @smells, churn, complexity).analysed_files
|
18
|
-
generate_report
|
19
|
-
end
|
20
|
-
|
21
|
-
def generate_report
|
22
|
-
raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "rubycritic/orchestrators/base"
|
2
|
-
require "rubycritic/reporters/main"
|
3
|
-
|
4
|
-
module Rubycritic
|
5
|
-
module Orchestrator
|
6
|
-
|
7
|
-
class Main < Base
|
8
|
-
def generate_report
|
9
|
-
Reporter::Main.new(@analysed_files, @smells).generate_report
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "rubycritic/orchestrators/base"
|
2
|
-
require "rubycritic/reporters/mini"
|
3
|
-
|
4
|
-
module Rubycritic
|
5
|
-
module Orchestrator
|
6
|
-
|
7
|
-
class Mini < Base
|
8
|
-
def generate_report
|
9
|
-
Reporter::Mini.new(@analysed_files.first).generate_report
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
|
3
|
-
module Rubycritic
|
4
|
-
|
5
|
-
class SmellsSerializer
|
6
|
-
def initialize(file_name)
|
7
|
-
@file_name = file_name
|
8
|
-
end
|
9
|
-
|
10
|
-
def load
|
11
|
-
Marshal.load(File.binread(@file_name))
|
12
|
-
end
|
13
|
-
|
14
|
-
def dump(smells)
|
15
|
-
create_file_directory
|
16
|
-
File.open(@file_name, "w+") do |file|
|
17
|
-
Marshal.dump(smells, file)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def create_file_directory
|
24
|
-
FileUtils.mkdir_p(file_directory)
|
25
|
-
end
|
26
|
-
|
27
|
-
def file_directory
|
28
|
-
File.dirname(@file_name)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Rubycritic
|
2
|
-
|
3
|
-
class SourceControlSystem
|
4
|
-
@@systems = []
|
5
|
-
|
6
|
-
def self.register_system
|
7
|
-
@@systems << self
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.create
|
11
|
-
supported_system = systems.detect(&:supported?)
|
12
|
-
if supported_system
|
13
|
-
supported_system.new
|
14
|
-
else
|
15
|
-
raise "Rubycritic requires a #{system_names} repository."
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.systems
|
20
|
-
@@systems
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.system_names
|
24
|
-
systems.join(", ")
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.supported?
|
28
|
-
raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
|
29
|
-
end
|
30
|
-
|
31
|
-
def has_revision?
|
32
|
-
raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
|
33
|
-
end
|
34
|
-
|
35
|
-
def head_reference
|
36
|
-
raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
|
37
|
-
end
|
38
|
-
|
39
|
-
def travel_to_head
|
40
|
-
raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
|
41
|
-
end
|
42
|
-
|
43
|
-
def revisions_count(file)
|
44
|
-
raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
require "rubycritic/source_control_systems/git"
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "rubycritic/analysed_files_builder"
|
3
|
-
|
4
|
-
describe Rubycritic::AnalysedFilesBuilder do
|
5
|
-
describe "analysed_files" do
|
6
|
-
before do
|
7
|
-
@pathnames = [Pathname.new("./foo"), Pathname.new("./bar")]
|
8
|
-
@smells = [SmellDouble.new]
|
9
|
-
@churn = [1, 2]
|
10
|
-
@complexity = [3, 4]
|
11
|
-
@builder = Rubycritic::AnalysedFilesBuilder.new(@pathnames, @smells, @churn, @complexity)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "returns an array of AnalysedFiles" do
|
15
|
-
analysed_files = @builder.analysed_files
|
16
|
-
first = analysed_files.first
|
17
|
-
last = analysed_files.last
|
18
|
-
|
19
|
-
first.pathname.must_equal Pathname.new("./foo")
|
20
|
-
first.smells.must_equal @smells
|
21
|
-
first.churn.must_equal @churn.first
|
22
|
-
first.complexity.must_equal @complexity.first
|
23
|
-
|
24
|
-
last.pathname.must_equal Pathname.new("./bar")
|
25
|
-
last.smells.must_equal @smells
|
26
|
-
last.churn.must_equal @churn.last
|
27
|
-
last.complexity.must_equal @complexity.last
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class SmellDouble
|
33
|
-
def at_pathname?(other_pathname)
|
34
|
-
true
|
35
|
-
end
|
36
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "rubycritic/analysers_runner"
|
3
|
-
|
4
|
-
describe Rubycritic::AnalysersRunner do
|
5
|
-
describe "#smells" do
|
6
|
-
it "returns the smells found by various analysers" do
|
7
|
-
smells = Rubycritic::AnalysersRunner.new("test/samples/analysers_runner/empty.rb").smells
|
8
|
-
smells.must_be_instance_of Array
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
File without changes
|