rubycritic 2.6.0 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -585
  3. data/.rubocop_todo.yml +36 -0
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +1 -1
  6. data/Rakefile +9 -9
  7. data/bin/rubycritic +2 -2
  8. data/features/command_line_interface/options.feature +1 -0
  9. data/features/step_definitions/rubycritic_steps.rb +1 -1
  10. data/features/step_definitions/sample_file_steps.rb +3 -3
  11. data/features/support/env.rb +6 -6
  12. data/lib/rubycritic.rb +1 -1
  13. data/lib/rubycritic/analysers/attributes.rb +6 -7
  14. data/lib/rubycritic/analysers/churn.rb +4 -6
  15. data/lib/rubycritic/analysers/complexity.rb +5 -7
  16. data/lib/rubycritic/analysers/helpers/ast_node.rb +4 -6
  17. data/lib/rubycritic/analysers/helpers/flay.rb +1 -3
  18. data/lib/rubycritic/analysers/helpers/flog.rb +5 -7
  19. data/lib/rubycritic/analysers/helpers/methods_counter.rb +1 -3
  20. data/lib/rubycritic/analysers/helpers/modules_locator.rb +3 -5
  21. data/lib/rubycritic/analysers/helpers/parser.rb +2 -2
  22. data/lib/rubycritic/analysers/helpers/reek.rb +1 -1
  23. data/lib/rubycritic/analysers/smells/flay.rb +14 -16
  24. data/lib/rubycritic/analysers/smells/flog.rb +15 -17
  25. data/lib/rubycritic/analysers/smells/reek.rb +11 -13
  26. data/lib/rubycritic/analysers_runner.rb +8 -10
  27. data/lib/rubycritic/browser.rb +17 -0
  28. data/lib/rubycritic/cli/application.rb +3 -3
  29. data/lib/rubycritic/cli/options.rb +29 -23
  30. data/lib/rubycritic/command_factory.rb +5 -5
  31. data/lib/rubycritic/commands/base.rb +2 -2
  32. data/lib/rubycritic/commands/ci.rb +4 -4
  33. data/lib/rubycritic/commands/default.rb +5 -5
  34. data/lib/rubycritic/commands/help.rb +1 -1
  35. data/lib/rubycritic/commands/status_reporter.rb +1 -1
  36. data/lib/rubycritic/commands/version.rb +2 -2
  37. data/lib/rubycritic/configuration.rb +4 -2
  38. data/lib/rubycritic/core/analysed_module.rb +15 -17
  39. data/lib/rubycritic/core/analysed_modules_collection.rb +3 -3
  40. data/lib/rubycritic/core/location.rb +4 -6
  41. data/lib/rubycritic/core/rating.rb +5 -7
  42. data/lib/rubycritic/core/smell.rb +11 -13
  43. data/lib/rubycritic/generators/console_report.rb +1 -1
  44. data/lib/rubycritic/generators/html/base.rb +9 -9
  45. data/lib/rubycritic/generators/html/code_file.rb +5 -7
  46. data/lib/rubycritic/generators/html/code_index.rb +3 -5
  47. data/lib/rubycritic/generators/html/line.rb +4 -6
  48. data/lib/rubycritic/generators/html/overview.rb +4 -6
  49. data/lib/rubycritic/generators/html/smells_index.rb +3 -5
  50. data/lib/rubycritic/generators/html/turbulence.rb +4 -6
  51. data/lib/rubycritic/generators/html/view_helpers.rb +4 -4
  52. data/lib/rubycritic/generators/html_report.rb +13 -9
  53. data/lib/rubycritic/generators/json/simple.rb +7 -9
  54. data/lib/rubycritic/generators/json_report.rb +1 -3
  55. data/lib/rubycritic/generators/text/list.rb +9 -9
  56. data/lib/rubycritic/reporter.rb +3 -5
  57. data/lib/rubycritic/revision_comparator.rb +6 -8
  58. data/lib/rubycritic/serializer.rb +2 -4
  59. data/lib/rubycritic/smells_status_setter.rb +2 -4
  60. data/lib/rubycritic/source_control_systems/base.rb +4 -6
  61. data/lib/rubycritic/source_control_systems/double.rb +1 -2
  62. data/lib/rubycritic/source_control_systems/git.rb +1 -3
  63. data/lib/rubycritic/source_control_systems/mercurial.rb +1 -3
  64. data/lib/rubycritic/source_locator.rb +5 -6
  65. data/lib/rubycritic/version.rb +1 -1
  66. data/rubycritic.gemspec +26 -25
  67. data/test/analysers_test_helper.rb +1 -1
  68. data/test/lib/rubycritic/analysers/churn_test.rb +9 -9
  69. data/test/lib/rubycritic/analysers/complexity_test.rb +5 -5
  70. data/test/lib/rubycritic/analysers/helpers/methods_counter_test.rb +12 -12
  71. data/test/lib/rubycritic/analysers/helpers/modules_locator_test.rb +25 -25
  72. data/test/lib/rubycritic/analysers/smells/flay_test.rb +12 -12
  73. data/test/lib/rubycritic/analysers/smells/flog_test.rb +7 -7
  74. data/test/lib/rubycritic/analysers/smells/reek_test.rb +8 -8
  75. data/test/lib/rubycritic/browser_test.rb +16 -0
  76. data/test/lib/rubycritic/commands/status_reporter_test.rb +31 -19
  77. data/test/lib/rubycritic/configuration_test.rb +10 -10
  78. data/test/lib/rubycritic/core/analysed_module_test.rb +37 -37
  79. data/test/lib/rubycritic/core/analysed_modules_collection_test.rb +32 -32
  80. data/test/lib/rubycritic/core/location_test.rb +16 -16
  81. data/test/lib/rubycritic/core/smell_test.rb +31 -31
  82. data/test/lib/rubycritic/core/smells_array_test.rb +18 -18
  83. data/test/lib/rubycritic/generators/console_report_test.rb +26 -26
  84. data/test/lib/rubycritic/generators/turbulence_test.rb +8 -8
  85. data/test/lib/rubycritic/generators/view_helpers_test.rb +36 -36
  86. data/test/lib/rubycritic/smells_status_setter_test.rb +7 -7
  87. data/test/lib/rubycritic/source_control_systems/base_test.rb +7 -7
  88. data/test/lib/rubycritic/source_control_systems/double_test.rb +3 -3
  89. data/test/lib/rubycritic/source_control_systems/git_test.rb +4 -4
  90. data/test/lib/rubycritic/source_control_systems/mercurial_test.rb +3 -3
  91. data/test/lib/rubycritic/source_locator_test.rb +30 -30
  92. data/test/lib/rubycritic/version_test.rb +4 -4
  93. data/test/test_helper.rb +4 -4
  94. metadata +30 -17
@@ -1,38 +1,38 @@
1
- require "test_helper"
2
- require "rubycritic/analysers/smells/flay"
3
- require "rubycritic/core/analysed_module"
4
- require "pathname"
1
+ require 'test_helper'
2
+ require 'rubycritic/analysers/smells/flay'
3
+ require 'rubycritic/core/analysed_module'
4
+ require 'pathname'
5
5
 
6
6
  describe Rubycritic::Analyser::FlaySmells do
7
- context "when analysing a bunch of files with duplicate code" do
7
+ context 'when analysing a bunch of files with duplicate code' do
8
8
  before do
9
9
  @analysed_modules = [
10
- Rubycritic::AnalysedModule.new(:pathname => Pathname.new("test/samples/flay/smelly.rb")),
11
- Rubycritic::AnalysedModule.new(:pathname => Pathname.new("test/samples/flay/smelly2.rb"))
10
+ Rubycritic::AnalysedModule.new(pathname: Pathname.new('test/samples/flay/smelly.rb')),
11
+ Rubycritic::AnalysedModule.new(pathname: Pathname.new('test/samples/flay/smelly2.rb'))
12
12
  ]
13
13
  Rubycritic::Analyser::FlaySmells.new(@analysed_modules).run
14
14
  end
15
15
 
16
- it "detects its smells" do
16
+ it 'detects its smells' do
17
17
  @analysed_modules.first.smells?.must_equal true
18
18
  end
19
19
 
20
- it "creates smells with messages" do
20
+ it 'creates smells with messages' do
21
21
  smell = @analysed_modules.first.smells.first
22
22
  smell.message.must_be_instance_of String
23
23
  end
24
24
 
25
- it "creates smells with scores" do
25
+ it 'creates smells with scores' do
26
26
  smell = @analysed_modules.first.smells.first
27
27
  smell.score.must_be_kind_of Numeric
28
28
  end
29
29
 
30
- it "creates smells with more than one location" do
30
+ it 'creates smells with more than one location' do
31
31
  smell = @analysed_modules.first.smells.first
32
32
  smell.multiple_locations?.must_equal true
33
33
  end
34
34
 
35
- it "calculates the mass of duplicate code" do
35
+ it 'calculates the mass of duplicate code' do
36
36
  @analysed_modules.first.duplication.must_be(:>, 0)
37
37
  end
38
38
  end
@@ -1,24 +1,24 @@
1
- require "analysers_test_helper"
2
- require "rubycritic/analysers/smells/flog"
1
+ require 'analysers_test_helper'
2
+ require 'rubycritic/analysers/smells/flog'
3
3
 
4
4
  describe Rubycritic::Analyser::FlogSmells do
5
- context "when analysing a complex file" do
5
+ context 'when analysing a complex file' do
6
6
  before do
7
- @analysed_module = AnalysedModuleDouble.new(:path => "test/samples/flog/smelly.rb", :smells => [])
7
+ @analysed_module = AnalysedModuleDouble.new(path: 'test/samples/flog/smelly.rb', smells: [])
8
8
  analysed_modules = [@analysed_module]
9
9
  Rubycritic::Analyser::FlogSmells.new(analysed_modules).run
10
10
  end
11
11
 
12
- it "detects its smells" do
12
+ it 'detects its smells' do
13
13
  @analysed_module.smells.length.must_equal 1
14
14
  end
15
15
 
16
- it "creates smells with messages" do
16
+ it 'creates smells with messages' do
17
17
  smell = @analysed_module.smells.first
18
18
  smell.message.must_be_instance_of String
19
19
  end
20
20
 
21
- it "creates smells with scores" do
21
+ it 'creates smells with scores' do
22
22
  smell = @analysed_module.smells.first
23
23
  smell.score.must_be :>, 0
24
24
  end
@@ -1,25 +1,25 @@
1
- require "analysers_test_helper"
2
- require "rubycritic/analysers/smells/reek"
1
+ require 'analysers_test_helper'
2
+ require 'rubycritic/analysers/smells/reek'
3
3
 
4
4
  describe Rubycritic::Analyser::ReekSmells do
5
- context "when analysing a smelly file" do
5
+ context 'when analysing a smelly file' do
6
6
  before do
7
- pathname = Pathname.new("test/samples/reek/smelly.rb")
8
- @analysed_module = AnalysedModuleDouble.new(:pathname => pathname, :smells => [])
7
+ pathname = Pathname.new('test/samples/reek/smelly.rb')
8
+ @analysed_module = AnalysedModuleDouble.new(pathname: pathname, smells: [])
9
9
  analysed_modules = [@analysed_module]
10
10
  Rubycritic::Analyser::ReekSmells.new(analysed_modules).run
11
11
  end
12
12
 
13
- it "detects its smells" do
13
+ it 'detects its smells' do
14
14
  @analysed_module.smells.length.must_equal 2
15
15
  end
16
16
 
17
- it "creates smells with messages" do
17
+ it 'creates smells with messages' do
18
18
  first_smell = @analysed_module.smells.first
19
19
  first_smell.message.must_equal "has boolean parameter 'reek'"
20
20
 
21
21
  last_smell = @analysed_module.smells.last
22
- last_smell.message.must_equal "has no descriptive comment"
22
+ last_smell.message.must_equal 'has no descriptive comment'
23
23
  end
24
24
  end
25
25
  end
@@ -0,0 +1,16 @@
1
+ require 'test_helper'
2
+ require 'rubycritic/browser'
3
+
4
+ describe Rubycritic::Browser do
5
+ before do
6
+ @report_path = 'tmp/rubycritic/overview.html'
7
+ @browser = Rubycritic::Browser.new @report_path
8
+ end
9
+
10
+ describe '#open' do
11
+ it 'should be open report with launch browser' do
12
+ Launchy.stubs(:open).returns(true)
13
+ @browser.open.must_equal true
14
+ end
15
+ end
16
+ end
@@ -1,66 +1,78 @@
1
- require "test_helper"
2
- require "rubycritic/commands/status_reporter"
3
- require "rubycritic/cli/options"
1
+ require 'test_helper'
2
+ require 'rubycritic/commands/status_reporter'
3
+ require 'rubycritic/cli/options'
4
4
 
5
5
  describe Rubycritic::Command::StatusReporter do
6
6
  let(:success_status) { Rubycritic::Command::StatusReporter::SUCCESS }
7
7
  let(:score_below_minimum) { Rubycritic::Command::StatusReporter::SCORE_BELOW_MINIMUM }
8
8
 
9
- describe "with default options" do
9
+ describe 'with default options' do
10
10
  before do
11
11
  @options = Rubycritic::Cli::Options.new([])
12
12
  @options.parse
13
13
  @reporter = Rubycritic::Command::StatusReporter.new(@options.to_h)
14
14
  end
15
15
 
16
- it "has a default" do
16
+ it 'has a default' do
17
17
  @reporter.status.must_equal success_status
18
18
  @reporter.status_message.must_be_nil
19
19
  end
20
20
 
21
- it "accept a score" do
21
+ it 'accept a score' do
22
22
  @reporter.score = 50
23
23
  @reporter.status.must_equal success_status
24
- @reporter.status_message.must_equal "Score: 50"
24
+ @reporter.status_message.must_equal 'Score: 50.0'
25
+ end
26
+
27
+ it 'should format the score' do
28
+ @reporter.score = 98.95258620689656
29
+ @reporter.status.must_equal success_status
30
+ @reporter.status_message.must_equal 'Score: 98.95'
25
31
  end
26
32
  end
27
33
 
28
- describe "with minimum-score option" do
34
+ describe 'with minimum-score option' do
29
35
  before do
30
- @options = Rubycritic::Cli::Options.new(["-s", "99"])
36
+ @options = Rubycritic::Cli::Options.new(['-s', '99'])
31
37
  @options.parse
32
38
  @reporter = Rubycritic::Command::StatusReporter.new(@options.to_h)
33
39
  end
34
40
 
35
- it "has a default" do
41
+ it 'has a default' do
36
42
  @reporter.status.must_equal success_status
37
43
  @reporter.status_message.must_be_nil
38
44
  end
39
45
 
40
- describe "when score is below minimum" do
46
+ describe 'when score is below minimum' do
41
47
  let(:score) { 98 }
42
- it "should return the correct status" do
48
+ it 'should return the correct status' do
43
49
  @reporter.score = score
44
50
  @reporter.status.must_equal score_below_minimum
45
- @reporter.status_message.must_equal "Score (98) is below the minimum 99"
51
+ @reporter.status_message.must_equal 'Score (98.0) is below the minimum 99'
52
+ end
53
+
54
+ it 'should format the score' do
55
+ @reporter.score = 98.95258620689656
56
+ @reporter.status.must_equal score_below_minimum
57
+ @reporter.status_message.must_equal 'Score (98.95) is below the minimum 99'
46
58
  end
47
59
  end
48
60
 
49
- describe "when score is equal the minimum" do
61
+ describe 'when score is equal the minimum' do
50
62
  let(:score) { 99 }
51
- it "should return the correct status" do
63
+ it 'should return the correct status' do
52
64
  @reporter.score = score
53
65
  @reporter.status.must_equal success_status
54
- @reporter.status_message.must_equal "Score: 99"
66
+ @reporter.status_message.must_equal 'Score: 99.0'
55
67
  end
56
68
  end
57
69
 
58
- describe "when score is above the minimum" do
70
+ describe 'when score is above the minimum' do
59
71
  let(:score) { 100 }
60
- it "should return the correct status" do
72
+ it 'should return the correct status' do
61
73
  @reporter.score = score
62
74
  @reporter.status.must_equal success_status
63
- @reporter.status_message.must_equal "Score: 100"
75
+ @reporter.status_message.must_equal 'Score: 100.0'
64
76
  end
65
77
  end
66
78
  end
@@ -1,25 +1,25 @@
1
- require "test_helper"
2
- require "rubycritic/configuration"
1
+ require 'test_helper'
2
+ require 'rubycritic/configuration'
3
3
 
4
4
  describe Rubycritic::Configuration do
5
- describe "#root" do
5
+ describe '#root' do
6
6
  before do
7
7
  Rubycritic::Config.set
8
8
  @default = Rubycritic::Config.root
9
9
  end
10
10
 
11
- it "has a default" do
11
+ it 'has a default' do
12
12
  Rubycritic::Config.root.must_be_instance_of String
13
13
  end
14
14
 
15
- it "can be set to a relative path" do
16
- Rubycritic::Config.root = "foo"
17
- Rubycritic::Config.root.must_equal File.expand_path("foo")
15
+ it 'can be set to a relative path' do
16
+ Rubycritic::Config.root = 'foo'
17
+ Rubycritic::Config.root.must_equal File.expand_path('foo')
18
18
  end
19
19
 
20
- it "can be set to an absolute path" do
21
- Rubycritic::Config.root = "/foo"
22
- Rubycritic::Config.root.must_equal "/foo"
20
+ it 'can be set to an absolute path' do
21
+ Rubycritic::Config.root = '/foo'
22
+ Rubycritic::Config.root.must_equal '/foo'
23
23
  end
24
24
 
25
25
  after do
@@ -1,85 +1,85 @@
1
- require "test_helper"
2
- require "rubycritic/core/analysed_module"
3
- require "rubycritic/core/smell"
1
+ require 'test_helper'
2
+ require 'rubycritic/core/analysed_module'
3
+ require 'rubycritic/core/smell'
4
4
 
5
5
  describe Rubycritic::AnalysedModule do
6
- describe "attribute readers" do
6
+ describe 'attribute readers' do
7
7
  before do
8
- @name = "Foo"
9
- @pathname = Pathname.new("foo.rb")
8
+ @name = 'Foo'
9
+ @pathname = Pathname.new('foo.rb')
10
10
  @smells = []
11
11
  @churn = 1
12
12
  @complexity = 2
13
13
  @analysed_module = Rubycritic::AnalysedModule.new(
14
- :name => @name,
15
- :pathname => @pathname,
16
- :smells => @smells,
17
- :churn => @churn,
18
- :complexity => @complexity
14
+ name: @name,
15
+ pathname: @pathname,
16
+ smells: @smells,
17
+ churn: @churn,
18
+ complexity: @complexity
19
19
  )
20
20
  end
21
21
 
22
- it "has a name reader" do
22
+ it 'has a name reader' do
23
23
  @analysed_module.name.must_equal @name
24
24
  end
25
25
 
26
- it "has a pathname reader" do
26
+ it 'has a pathname reader' do
27
27
  @analysed_module.pathname.must_equal @pathname
28
28
  end
29
29
 
30
- it "has a path reader" do
30
+ it 'has a path reader' do
31
31
  @analysed_module.path.must_equal @pathname.to_s
32
32
  end
33
33
 
34
- it "has a smells reader" do
34
+ it 'has a smells reader' do
35
35
  @analysed_module.smells.must_equal @smells
36
36
  end
37
37
 
38
- it "has a churn reader" do
38
+ it 'has a churn reader' do
39
39
  @analysed_module.churn.must_equal @churn
40
40
  end
41
41
 
42
- it "has a complexity reader" do
42
+ it 'has a complexity reader' do
43
43
  @analysed_module.complexity.must_equal @complexity
44
44
  end
45
45
  end
46
46
 
47
- describe "#cost" do
48
- it "returns the remediation cost of fixing the analysed_module" do
49
- smells = [SmellDouble.new(:cost => 1), SmellDouble.new(:cost => 2)]
50
- analysed_module = Rubycritic::AnalysedModule.new(:smells => smells, :complexity => 0)
47
+ describe '#cost' do
48
+ it 'returns the remediation cost of fixing the analysed_module' do
49
+ smells = [SmellDouble.new(cost: 1), SmellDouble.new(cost: 2)]
50
+ analysed_module = Rubycritic::AnalysedModule.new(smells: smells, complexity: 0)
51
51
  analysed_module.cost.must_equal 3
52
52
  end
53
53
  end
54
54
 
55
- describe "#complexity_per_method" do
56
- context "when the file has no methods" do
57
- it "returns a placeholder" do
58
- analysed_module = Rubycritic::AnalysedModule.new(:complexity => 0, :methods_count => 0)
59
- analysed_module.complexity_per_method.must_equal "N/A"
55
+ describe '#complexity_per_method' do
56
+ context 'when the file has no methods' do
57
+ it 'returns a placeholder' do
58
+ analysed_module = Rubycritic::AnalysedModule.new(complexity: 0, methods_count: 0)
59
+ analysed_module.complexity_per_method.must_equal 'N/A'
60
60
  end
61
61
  end
62
62
 
63
- context "when the file has at least one method" do
64
- it "returns the average complexity per method" do
65
- analysed_module = Rubycritic::AnalysedModule.new(:complexity => 10, :methods_count => 2)
63
+ context 'when the file has at least one method' do
64
+ it 'returns the average complexity per method' do
65
+ analysed_module = Rubycritic::AnalysedModule.new(complexity: 10, methods_count: 2)
66
66
  analysed_module.complexity_per_method.must_equal 5
67
67
  end
68
68
  end
69
69
  end
70
70
 
71
- describe "#smells?" do
72
- it "returns true if the analysed_module has at least one smell" do
73
- analysed_module = Rubycritic::AnalysedModule.new(:smells => [SmellDouble.new])
71
+ describe '#smells?' do
72
+ it 'returns true if the analysed_module has at least one smell' do
73
+ analysed_module = Rubycritic::AnalysedModule.new(smells: [SmellDouble.new])
74
74
  analysed_module.smells?.must_equal true
75
75
  end
76
76
  end
77
77
 
78
- describe "#smells_at_location" do
79
- it "returns the smells of an analysed_module at a certain location" do
80
- location = Rubycritic::Location.new("./foo", "42")
81
- smells = [Rubycritic::Smell.new(:locations => [location])]
82
- analysed_module = Rubycritic::AnalysedModule.new(:smells => smells)
78
+ describe '#smells_at_location' do
79
+ it 'returns the smells of an analysed_module at a certain location' do
80
+ location = Rubycritic::Location.new('./foo', '42')
81
+ smells = [Rubycritic::Smell.new(locations: [location])]
82
+ analysed_module = Rubycritic::AnalysedModule.new(smells: smells)
83
83
  analysed_module.smells_at_location(location).must_equal smells
84
84
  end
85
85
  end
@@ -1,62 +1,62 @@
1
- require "test_helper"
2
- require "rubycritic/core/analysed_modules_collection"
1
+ require 'test_helper'
2
+ require 'rubycritic/core/analysed_modules_collection'
3
3
 
4
4
  describe Rubycritic::AnalysedModulesCollection do
5
5
  subject { Rubycritic::AnalysedModulesCollection.new(paths) }
6
6
 
7
- describe ".new" do
8
- context "with an empty path" do
9
- let(:paths) { "" }
7
+ describe '.new' do
8
+ context 'with an empty path' do
9
+ let(:paths) { '' }
10
10
 
11
- it "returns an empty collection" do
11
+ it 'returns an empty collection' do
12
12
  subject.count.must_equal 0
13
13
  end
14
14
  end
15
15
 
16
- context "with a list of files" do
16
+ context 'with a list of files' do
17
17
  let(:paths) { %w(test/samples/doesnt_exist.rb test/samples/unparsable.rb test/samples/empty.rb) }
18
18
 
19
- it "registers one AnalysedModule element per existent file" do
19
+ it 'registers one AnalysedModule element per existent file' do
20
20
  subject.count.must_equal 2
21
21
  subject.all? { |a| a.is_a?(Rubycritic::AnalysedModule) }.must_equal true
22
22
  end
23
23
  end
24
24
 
25
- context "with a directory" do
26
- let(:paths) { "test/samples/" }
25
+ context 'with a directory' do
26
+ let(:paths) { 'test/samples/' }
27
27
 
28
- it "recursively registers all files" do
29
- subject.count.must_equal Dir["test/samples/**/*.rb"].count
28
+ it 'recursively registers all files' do
29
+ subject.count.must_equal Dir['test/samples/**/*.rb'].count
30
30
  end
31
31
  end
32
32
 
33
- context "with redundant paths" do
33
+ context 'with redundant paths' do
34
34
  let(:paths) { %w(test/samples/flog test/samples/flog/complex.rb) }
35
35
 
36
- it "returns a redundant collection" do
36
+ it 'returns a redundant collection' do
37
37
  subject.count.must_equal 3
38
38
  end
39
39
  end
40
40
  end
41
41
 
42
- describe "#score" do
43
- context "with no modules" do
44
- let(:paths) { "" }
42
+ describe '#score' do
43
+ context 'with no modules' do
44
+ let(:paths) { '' }
45
45
 
46
- it "returns zero" do
46
+ it 'returns zero' do
47
47
  subject.score.must_equal 0.0
48
48
  end
49
49
  end
50
50
 
51
- context "with not analysed modules" do
52
- let(:paths) { "test/samples/flog" }
51
+ context 'with not analysed modules' do
52
+ let(:paths) { 'test/samples/flog' }
53
53
 
54
- it "returns zero" do
54
+ it 'returns zero' do
55
55
  subject.score.must_equal 0.0
56
56
  end
57
57
  end
58
58
 
59
- context "with analysed modules" do
59
+ context 'with analysed modules' do
60
60
  before do
61
61
  subject.each_with_index do |mod, i|
62
62
  mod.expects(:cost).returns costs[i]
@@ -65,42 +65,42 @@ describe Rubycritic::AnalysedModulesCollection do
65
65
 
66
66
  let(:paths) { %w(test/samples/flog test/samples/flay) }
67
67
 
68
- context "with perfect modules" do
68
+ context 'with perfect modules' do
69
69
  let(:costs) { [0.0, 0.0, 0.0, 0.0] }
70
70
 
71
- it "returns the maximum score" do
71
+ it 'returns the maximum score' do
72
72
  subject.score.must_equal 100.0
73
73
  end
74
74
  end
75
75
 
76
- context "with very bad modules" do
76
+ context 'with very bad modules' do
77
77
  let(:costs) { [16.0, 16.0, 16.0, 16.0] }
78
78
 
79
- it "returns zero" do
79
+ it 'returns zero' do
80
80
  subject.score.must_equal 0.0
81
81
  end
82
82
  end
83
83
 
84
- context "with horrible modules" do
84
+ context 'with horrible modules' do
85
85
  let(:costs) { [32.0, 32.0, 32.0, 32.0] }
86
86
 
87
- it "returns zero" do
87
+ it 'returns zero' do
88
88
  subject.score.must_equal 0.0
89
89
  end
90
90
  end
91
91
 
92
- context "with mixed modules" do
92
+ context 'with mixed modules' do
93
93
  let(:costs) { [32.0, 2.0, 0.0, 2.0] }
94
94
 
95
- it "properly calculates the score" do
95
+ it 'properly calculates the score' do
96
96
  subject.score.must_equal 43.75
97
97
  end
98
98
  end
99
99
 
100
- context "with a module above the cost limit" do
100
+ context 'with a module above the cost limit' do
101
101
  let(:costs) { [220.0, 2.0, 0.0, 2.0] }
102
102
 
103
- it "reduces the impact in the result" do
103
+ it 'reduces the impact in the result' do
104
104
  subject.score.must_equal 43.75
105
105
  end
106
106
  end