rubycritic 2.9.2 → 2.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop_todo.yml +6 -0
  4. data/.todo.reek +111 -108
  5. data/CHANGELOG.md +5 -0
  6. data/README.md +1 -1
  7. data/Rakefile +1 -1
  8. data/bin/rubycritic +1 -1
  9. data/features/command_line_interface/minimum_score.feature +1 -1
  10. data/features/command_line_interface/options.feature +2 -2
  11. data/features/rake_task.feature +5 -5
  12. data/features/step_definitions/rubycritic_steps.rb +4 -4
  13. data/features/support/env.rb +2 -2
  14. data/lib/rubycritic/analysers/attributes.rb +1 -1
  15. data/lib/rubycritic/analysers/churn.rb +1 -1
  16. data/lib/rubycritic/analysers/complexity.rb +1 -1
  17. data/lib/rubycritic/analysers/helpers/ast_node.rb +1 -1
  18. data/lib/rubycritic/analysers/helpers/flay.rb +1 -1
  19. data/lib/rubycritic/analysers/helpers/flog.rb +1 -1
  20. data/lib/rubycritic/analysers/helpers/methods_counter.rb +1 -1
  21. data/lib/rubycritic/analysers/helpers/modules_locator.rb +1 -1
  22. data/lib/rubycritic/analysers/helpers/parser.rb +1 -1
  23. data/lib/rubycritic/analysers/helpers/reek.rb +1 -1
  24. data/lib/rubycritic/analysers/smells/flay.rb +1 -1
  25. data/lib/rubycritic/analysers/smells/flog.rb +1 -1
  26. data/lib/rubycritic/analysers/smells/reek.rb +1 -1
  27. data/lib/rubycritic/analysers_runner.rb +1 -1
  28. data/lib/rubycritic/browser.rb +1 -1
  29. data/lib/rubycritic/cli/application.rb +2 -2
  30. data/lib/rubycritic/cli/options.rb +1 -1
  31. data/lib/rubycritic/colorize.rb +1 -1
  32. data/lib/rubycritic/command_factory.rb +1 -1
  33. data/lib/rubycritic/commands/base.rb +2 -2
  34. data/lib/rubycritic/commands/ci.rb +1 -1
  35. data/lib/rubycritic/commands/default.rb +1 -1
  36. data/lib/rubycritic/commands/help.rb +1 -1
  37. data/lib/rubycritic/commands/status_reporter.rb +1 -1
  38. data/lib/rubycritic/commands/version.rb +1 -1
  39. data/lib/rubycritic/configuration.rb +5 -1
  40. data/lib/rubycritic/core/analysed_module.rb +2 -2
  41. data/lib/rubycritic/core/analysed_modules_collection.rb +1 -1
  42. data/lib/rubycritic/core/location.rb +1 -1
  43. data/lib/rubycritic/core/rating.rb +1 -1
  44. data/lib/rubycritic/core/smell.rb +1 -1
  45. data/lib/rubycritic/generators/console_report.rb +1 -1
  46. data/lib/rubycritic/generators/html/assets/javascripts/jquery-2.1.0.js +1 -1
  47. data/lib/rubycritic/generators/html/base.rb +1 -1
  48. data/lib/rubycritic/generators/html/code_file.rb +1 -1
  49. data/lib/rubycritic/generators/html/code_index.rb +1 -1
  50. data/lib/rubycritic/generators/html/line.rb +1 -1
  51. data/lib/rubycritic/generators/html/overview.rb +1 -1
  52. data/lib/rubycritic/generators/html/smells_index.rb +1 -1
  53. data/lib/rubycritic/generators/html/turbulence.rb +1 -1
  54. data/lib/rubycritic/generators/html/view_helpers.rb +1 -1
  55. data/lib/rubycritic/generators/html_report.rb +2 -2
  56. data/lib/rubycritic/generators/json/simple.rb +13 -2
  57. data/lib/rubycritic/generators/json_report.rb +5 -2
  58. data/lib/rubycritic/generators/text/list.rb +1 -1
  59. data/lib/rubycritic/rake_task.rb +2 -2
  60. data/lib/rubycritic/reporter.rb +1 -1
  61. data/lib/rubycritic/revision_comparator.rb +1 -1
  62. data/lib/rubycritic/serializer.rb +1 -1
  63. data/lib/rubycritic/smells_status_setter.rb +1 -1
  64. data/lib/rubycritic/source_control_systems/base.rb +1 -1
  65. data/lib/rubycritic/source_control_systems/double.rb +1 -1
  66. data/lib/rubycritic/source_control_systems/git.rb +1 -1
  67. data/lib/rubycritic/source_control_systems/mercurial.rb +1 -1
  68. data/lib/rubycritic/source_locator.rb +1 -1
  69. data/lib/rubycritic/version.rb +2 -2
  70. data/lib/rubycritic.rb +1 -1
  71. data/rubycritic.gemspec +2 -1
  72. data/test/lib/rubycritic/analysers/churn_test.rb +3 -3
  73. data/test/lib/rubycritic/analysers/complexity_test.rb +2 -2
  74. data/test/lib/rubycritic/analysers/helpers/methods_counter_test.rb +4 -4
  75. data/test/lib/rubycritic/analysers/helpers/modules_locator_test.rb +9 -9
  76. data/test/lib/rubycritic/analysers/smells/flay_test.rb +4 -4
  77. data/test/lib/rubycritic/analysers/smells/flog_test.rb +2 -2
  78. data/test/lib/rubycritic/analysers/smells/reek_test.rb +2 -2
  79. data/test/lib/rubycritic/browser_test.rb +2 -2
  80. data/test/lib/rubycritic/commands/status_reporter_test.rb +7 -7
  81. data/test/lib/rubycritic/configuration_test.rb +9 -9
  82. data/test/lib/rubycritic/core/analysed_module_test.rb +9 -9
  83. data/test/lib/rubycritic/core/analysed_modules_collection_test.rb +3 -3
  84. data/test/lib/rubycritic/core/location_test.rb +7 -7
  85. data/test/lib/rubycritic/core/smell_test.rb +15 -15
  86. data/test/lib/rubycritic/core/smells_array_test.rb +12 -12
  87. data/test/lib/rubycritic/generators/console_report_test.rb +5 -5
  88. data/test/lib/rubycritic/generators/json_report_test.rb +36 -0
  89. data/test/lib/rubycritic/generators/turbulence_test.rb +2 -2
  90. data/test/lib/rubycritic/generators/view_helpers_test.rb +2 -2
  91. data/test/lib/rubycritic/revision_comparator_test.rb +10 -10
  92. data/test/lib/rubycritic/smells_status_setter_test.rb +4 -4
  93. data/test/lib/rubycritic/source_control_systems/base_test.rb +7 -7
  94. data/test/lib/rubycritic/source_control_systems/double_test.rb +1 -1
  95. data/test/lib/rubycritic/source_control_systems/git_test.rb +1 -1
  96. data/test/lib/rubycritic/source_control_systems/mercurial_test.rb +1 -1
  97. data/test/lib/rubycritic/source_locator_test.rb +12 -12
  98. data/test/lib/rubycritic/version_test.rb +2 -2
  99. metadata +18 -2
@@ -4,7 +4,7 @@ require 'rubycritic/revision_comparator'
4
4
  require 'rubycritic/reporter'
5
5
  require 'rubycritic/commands/base'
6
6
 
7
- module Rubycritic
7
+ module RubyCritic
8
8
  module Command
9
9
  class Default < Base
10
10
  def initialize(options)
@@ -1,6 +1,6 @@
1
1
  require 'rubycritic/commands/base'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  module Command
5
5
  class Help < Base
6
6
  def execute
@@ -1,4 +1,4 @@
1
- module Rubycritic
1
+ module RubyCritic
2
2
  module Command
3
3
  class StatusReporter
4
4
  attr_reader :status, :status_message
@@ -1,7 +1,7 @@
1
1
  require 'rubycritic/version'
2
2
  require 'rubycritic/commands/base'
3
3
 
4
- module Rubycritic
4
+ module RubyCritic
5
5
  module Command
6
6
  class Version < Base
7
7
  def execute
@@ -1,4 +1,4 @@
1
- module Rubycritic
1
+ module RubyCritic
2
2
  class Configuration
3
3
  attr_reader :root
4
4
  attr_accessor :source_control_system, :mode, :format, :deduplicate_symlinks,
@@ -31,5 +31,9 @@ module Rubycritic
31
31
  def self.method_missing(method, *args, &block)
32
32
  configuration.public_send(method, *args, &block)
33
33
  end
34
+
35
+ def self.respond_to_missing?(symbol, include_all = false)
36
+ configuration.respond_to_missing?(symbol) || super
37
+ end
34
38
  end
35
39
  end
@@ -1,7 +1,7 @@
1
1
  require 'virtus'
2
2
  require 'rubycritic/core/rating'
3
3
 
4
- module Rubycritic
4
+ module RubyCritic
5
5
  class AnalysedModule
6
6
  include Virtus.model
7
7
 
@@ -27,7 +27,7 @@ module Rubycritic
27
27
  end
28
28
 
29
29
  def complexity_per_method
30
- if methods_count == 0
30
+ if methods_count.zero?
31
31
  'N/A'
32
32
  else
33
33
  complexity.fdiv(methods_count).round(1)
@@ -1,7 +1,7 @@
1
1
  require 'rubycritic/source_locator'
2
2
  require 'rubycritic/core/analysed_module'
3
3
 
4
- module Rubycritic
4
+ module RubyCritic
5
5
  class AnalysedModulesCollection
6
6
  include Enumerable
7
7
 
@@ -1,6 +1,6 @@
1
1
  require 'pathname'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  class Location
5
5
  attr_reader :pathname, :line
6
6
 
@@ -1,4 +1,4 @@
1
- module Rubycritic
1
+ module RubyCritic
2
2
  class Rating
3
3
  def self.from_cost(cost)
4
4
  if cost <= 2 then new('A')
@@ -1,7 +1,7 @@
1
1
  require 'virtus'
2
2
  require 'rubycritic/core/location'
3
3
 
4
- module Rubycritic
4
+ module RubyCritic
5
5
  class Smell
6
6
  include Virtus.model
7
7
 
@@ -1,6 +1,6 @@
1
1
  require 'rubycritic/generators/text/list'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  module Generator
5
5
  class ConsoleReport
6
6
  def initialize(analysed_modules)
@@ -9108,4 +9108,4 @@ if ( typeof noGlobal === strundefined ) {
9108
9108
 
9109
9109
  return jQuery;
9110
9110
 
9111
- }));
9111
+ }));
@@ -2,7 +2,7 @@ require 'erb'
2
2
  require 'pathname'
3
3
  require 'rubycritic/generators/html/view_helpers'
4
4
 
5
- module Rubycritic
5
+ module RubyCritic
6
6
  module Generator
7
7
  module Html
8
8
  class Base
@@ -1,7 +1,7 @@
1
1
  require 'rubycritic/generators/html/base'
2
2
  require 'rubycritic/generators/html/line'
3
3
 
4
- module Rubycritic
4
+ module RubyCritic
5
5
  module Generator
6
6
  module Html
7
7
  class CodeFile < Base
@@ -1,6 +1,6 @@
1
1
  require 'rubycritic/generators/html/base'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  module Generator
5
5
  module Html
6
6
  class CodeIndex < Base
@@ -1,7 +1,7 @@
1
1
  require 'cgi'
2
2
  require 'rubycritic/generators/html/base'
3
3
 
4
- module Rubycritic
4
+ module RubyCritic
5
5
  module Generator
6
6
  module Html
7
7
  class Line < Base
@@ -1,7 +1,7 @@
1
1
  require 'rubycritic/generators/html/base'
2
2
  require 'rubycritic/generators/html/turbulence'
3
3
 
4
- module Rubycritic
4
+ module RubyCritic
5
5
  module Generator
6
6
  module Html
7
7
  class Overview < Base
@@ -1,6 +1,6 @@
1
1
  require 'rubycritic/generators/html/base'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  module Generator
5
5
  module Html
6
6
  class SmellsIndex < Base
@@ -1,6 +1,6 @@
1
1
  require 'json'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  module Turbulence
5
5
  def self.data(analysed_modules)
6
6
  analysed_modules.map do |analysed_module|
@@ -1,4 +1,4 @@
1
- module Rubycritic
1
+ module RubyCritic
2
2
  module ViewHelpers
3
3
  def timeago_tag(time)
4
4
  "<time class='js-timeago' datetime='#{time}'>#{time}</time>"
@@ -5,7 +5,7 @@ require 'rubycritic/generators/html/smells_index'
5
5
  require 'rubycritic/generators/html/code_index'
6
6
  require 'rubycritic/generators/html/code_file'
7
7
 
8
- module Rubycritic
8
+ module RubyCritic
9
9
  module Generator
10
10
  class HtmlReport
11
11
  ASSETS_DIR = File.expand_path('../html/assets', __FILE__)
@@ -22,7 +22,7 @@ module Rubycritic
22
22
  end
23
23
 
24
24
  def browser
25
- @browser ||= Rubycritic::Browser.new(report_location)
25
+ @browser ||= RubyCritic::Browser.new(report_location)
26
26
  end
27
27
 
28
28
  private
@@ -1,7 +1,8 @@
1
1
  require 'json'
2
2
  require 'rubycritic/version'
3
+ require 'pathname'
3
4
 
4
- module Rubycritic
5
+ module RubyCritic
5
6
  module Generator
6
7
  module Json
7
8
  class Simple
@@ -9,6 +10,8 @@ module Rubycritic
9
10
  @analysed_modules = analysed_modules
10
11
  end
11
12
 
13
+ FILE_NAME = 'report.json'.freeze
14
+
12
15
  def render
13
16
  JSON.dump(data)
14
17
  end
@@ -17,13 +20,21 @@ module Rubycritic
17
20
  {
18
21
  metadata: {
19
22
  rubycritic: {
20
- version: Rubycritic::VERSION
23
+ version: RubyCritic::VERSION
21
24
  }
22
25
  },
23
26
  analysed_modules: @analysed_modules,
24
27
  score: @analysed_modules.score
25
28
  }
26
29
  end
30
+
31
+ def file_directory
32
+ @file_directory ||= Pathname.new(Config.root)
33
+ end
34
+
35
+ def file_pathname
36
+ Pathname.new(file_directory).join FILE_NAME
37
+ end
27
38
  end
28
39
  end
29
40
  end
@@ -1,6 +1,6 @@
1
1
  require 'rubycritic/generators/json/simple'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  module Generator
5
5
  class JsonReport
6
6
  def initialize(analysed_modules)
@@ -8,7 +8,10 @@ module Rubycritic
8
8
  end
9
9
 
10
10
  def generate_report
11
- print generator.render
11
+ FileUtils.mkdir_p(generator.file_directory)
12
+ File.open(generator.file_pathname, 'w+') do |file|
13
+ file.write(generator.render)
14
+ end
12
15
  end
13
16
 
14
17
  private
@@ -1,6 +1,6 @@
1
1
  require 'colorize'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  module Generator
5
5
  module Text
6
6
  class List
@@ -3,7 +3,7 @@ require 'rake/tasklib'
3
3
  require 'English'
4
4
  require 'rubycritic/cli/application'
5
5
 
6
- module Rubycritic
6
+ module RubyCritic
7
7
  #
8
8
  # A rake task that runs RubyCritic on a set of source files.
9
9
  #
@@ -58,7 +58,7 @@ module Rubycritic
58
58
  puts "\n\n!!! Running `#{name}` rake command\n"
59
59
  puts "!!! Inspecting #{paths} #{options.empty? ? '' : "with options #{options}"}\n\n"
60
60
  end
61
- application = Rubycritic::Cli::Application.new(options_as_arguments + paths)
61
+ application = RubyCritic::Cli::Application.new(options_as_arguments + paths)
62
62
  application.execute
63
63
  end
64
64
 
@@ -1,4 +1,4 @@
1
- module Rubycritic
1
+ module RubyCritic
2
2
  module Reporter
3
3
  def self.generate_report(analysed_modules)
4
4
  report_generator_class.new(analysed_modules).generate_report
@@ -6,7 +6,7 @@ require 'rubycritic/smells_status_setter'
6
6
  require 'rubycritic/version'
7
7
  require 'digest/md5'
8
8
 
9
- module Rubycritic
9
+ module RubyCritic
10
10
  class RevisionComparator
11
11
  SNAPSHOTS_DIR_NAME = 'snapshots'.freeze
12
12
 
@@ -1,6 +1,6 @@
1
1
  require 'fileutils'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  class Serializer
5
5
  def initialize(file)
6
6
  @file = file
@@ -1,4 +1,4 @@
1
- module Rubycritic
1
+ module RubyCritic
2
2
  module SmellsStatusSetter
3
3
  def self.set(smells_before, smells_now)
4
4
  old_smells = smells_now & smells_before
@@ -1,6 +1,6 @@
1
1
  require 'shellwords'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  module SourceControlSystem
5
5
  class Base
6
6
  @@systems = []
@@ -1,4 +1,4 @@
1
- module Rubycritic
1
+ module RubyCritic
2
2
  module SourceControlSystem
3
3
  class Double < Base
4
4
  def revisions_count(_)
@@ -1,4 +1,4 @@
1
- module Rubycritic
1
+ module RubyCritic
2
2
  module SourceControlSystem
3
3
  class Git < Base
4
4
  register_system
@@ -1,4 +1,4 @@
1
- module Rubycritic
1
+ module RubyCritic
2
2
  module SourceControlSystem
3
3
  class Mercurial < Base
4
4
  register_system
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'pathname'
4
4
 
5
- module Rubycritic
5
+ module RubyCritic
6
6
  class SourceLocator
7
7
  RUBY_EXTENSION = '.rb'.freeze
8
8
  RUBY_FILES = File.join('**', "*#{RUBY_EXTENSION}")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rubycritic
4
- VERSION = '2.9.2'.freeze
3
+ module RubyCritic
4
+ VERSION = '2.9.3'.freeze
5
5
  end
data/lib/rubycritic.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'rubycritic/command_factory'
2
2
 
3
- module Rubycritic
3
+ module RubyCritic
4
4
  end
data/rubycritic.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'rubycritic/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'rubycritic'
8
- spec.version = Rubycritic::VERSION
8
+ spec.version = RubyCritic::VERSION
9
9
  spec.authors = ['Guilherme Simoes']
10
10
  spec.email = ['guilherme.rdems@gmail.com']
11
11
  spec.description = 'RubyCritic is a tool that wraps around various static analysis gems '\
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'aruba'
33
33
  spec.add_development_dependency 'bundler', '~> 1.3'
34
34
  spec.add_development_dependency 'cucumber'
35
+ spec.add_development_dependency 'fakefs'
35
36
  spec.add_development_dependency 'rake'
36
37
  spec.add_development_dependency 'minitest', '~> 5.3'
37
38
  spec.add_development_dependency 'mocha', '~> 1.1'
@@ -2,12 +2,12 @@ require 'analysers_test_helper'
2
2
  require 'rubycritic/analysers/churn'
3
3
  require 'rubycritic/source_control_systems/base'
4
4
 
5
- describe Rubycritic::Analyser::Churn do
5
+ describe RubyCritic::Analyser::Churn do
6
6
  context 'when analysing a file' do
7
7
  before do
8
8
  @analysed_module = AnalysedModuleDouble.new(path: 'path_to_some_file.rb')
9
9
  analysed_modules = [@analysed_module]
10
- analyser = Rubycritic::Analyser::Churn.new(analysed_modules)
10
+ analyser = RubyCritic::Analyser::Churn.new(analysed_modules)
11
11
  analyser.source_control_system = SourceControlSystemDouble.new
12
12
  analyser.run
13
13
  end
@@ -22,7 +22,7 @@ describe Rubycritic::Analyser::Churn do
22
22
  end
23
23
  end
24
24
 
25
- class SourceControlSystemDouble < Rubycritic::SourceControlSystem::Base
25
+ class SourceControlSystemDouble < RubyCritic::SourceControlSystem::Base
26
26
  def revisions_count(_path)
27
27
  1 # churn
28
28
  end
@@ -1,12 +1,12 @@
1
1
  require 'analysers_test_helper'
2
2
  require 'rubycritic/analysers/complexity'
3
3
 
4
- describe Rubycritic::Analyser::Complexity do
4
+ describe RubyCritic::Analyser::Complexity do
5
5
  context 'when analysing a file' do
6
6
  before do
7
7
  @analysed_module = AnalysedModuleDouble.new(path: 'test/samples/flog/complex.rb', smells: [])
8
8
  analysed_modules = [@analysed_module]
9
- Rubycritic::Analyser::Complexity.new(analysed_modules).run
9
+ RubyCritic::Analyser::Complexity.new(analysed_modules).run
10
10
  end
11
11
 
12
12
  it 'calculates its complexity' do
@@ -1,19 +1,19 @@
1
1
  require 'analysers_test_helper'
2
2
  require 'rubycritic/analysers/helpers/methods_counter'
3
3
 
4
- describe Rubycritic::MethodsCounter do
4
+ describe RubyCritic::MethodsCounter do
5
5
  describe '#count' do
6
6
  context 'when a file contains Ruby code' do
7
7
  it 'calculates the number of methods' do
8
8
  analysed_module = AnalysedModuleDouble.new(path: 'test/samples/methods_count.rb')
9
- Rubycritic::MethodsCounter.new(analysed_module).count.must_equal 2
9
+ RubyCritic::MethodsCounter.new(analysed_module).count.must_equal 2
10
10
  end
11
11
  end
12
12
 
13
13
  context 'when a file is empty' do
14
14
  it 'returns 0 as the number of methods' do
15
15
  analysed_module = AnalysedModuleDouble.new(path: 'test/samples/empty.rb')
16
- Rubycritic::MethodsCounter.new(analysed_module).count.must_equal 0
16
+ RubyCritic::MethodsCounter.new(analysed_module).count.must_equal 0
17
17
  end
18
18
  end
19
19
 
@@ -21,7 +21,7 @@ describe Rubycritic::MethodsCounter do
21
21
  it 'does not blow up and returns 0 as the number of methods' do
22
22
  analysed_module = AnalysedModuleDouble.new(path: 'test/samples/unparsable.rb')
23
23
  capture_output_streams do
24
- Rubycritic::MethodsCounter.new(analysed_module).count.must_equal 0
24
+ RubyCritic::MethodsCounter.new(analysed_module).count.must_equal 0
25
25
  end
26
26
  end
27
27
  end
@@ -3,49 +3,49 @@ require 'rubycritic/analysers/helpers/modules_locator'
3
3
  require 'rubycritic/core/analysed_module'
4
4
  require 'pathname'
5
5
 
6
- describe Rubycritic::ModulesLocator do
6
+ describe RubyCritic::ModulesLocator do
7
7
  describe '#names' do
8
8
  context 'when a file contains Ruby code' do
9
9
  it 'returns the names of all the classes and modules inside the file' do
10
- analysed_module = Rubycritic::AnalysedModule.new(
10
+ analysed_module = RubyCritic::AnalysedModule.new(
11
11
  pathname: Pathname.new('test/samples/module_names.rb'),
12
12
  methods_count: 1
13
13
  )
14
- Rubycritic::ModulesLocator.new(analysed_module).names
14
+ RubyCritic::ModulesLocator.new(analysed_module).names
15
15
  .must_equal ['Foo', 'Foo::Bar', 'Foo::Baz', 'Foo::Qux', 'Foo::Quux::Corge']
16
16
  end
17
17
  end
18
18
 
19
19
  context 'when a file is empty' do
20
20
  it 'returns the name of the file titleized' do
21
- analysed_module = Rubycritic::AnalysedModule.new(
21
+ analysed_module = RubyCritic::AnalysedModule.new(
22
22
  pathname: Pathname.new('test/samples/empty.rb'),
23
23
  methods_count: 1
24
24
  )
25
- Rubycritic::ModulesLocator.new(analysed_module).names.must_equal ['Empty']
25
+ RubyCritic::ModulesLocator.new(analysed_module).names.must_equal ['Empty']
26
26
  end
27
27
  end
28
28
 
29
29
  context 'when a file is unparsable' do
30
30
  it 'does not blow up and returns the name of the file titleized' do
31
- analysed_module = Rubycritic::AnalysedModule.new(
31
+ analysed_module = RubyCritic::AnalysedModule.new(
32
32
  pathname: Pathname.new('test/samples/unparsable.rb'),
33
33
  methods_count: 1
34
34
  )
35
35
  capture_output_streams do
36
- Rubycritic::ModulesLocator.new(analysed_module).names.must_equal ['Unparsable']
36
+ RubyCritic::ModulesLocator.new(analysed_module).names.must_equal ['Unparsable']
37
37
  end
38
38
  end
39
39
  end
40
40
 
41
41
  context 'when a file has no methods' do
42
42
  it 'returns the names of all the classes and modules inside the file' do
43
- analysed_module = Rubycritic::AnalysedModule.new(
43
+ analysed_module = RubyCritic::AnalysedModule.new(
44
44
  pathname: Pathname.new('test/samples/no_methods.rb'),
45
45
  methods_count: 0
46
46
  )
47
47
  capture_output_streams do
48
- Rubycritic::ModulesLocator.new(analysed_module).names.must_equal ['Foo::NoMethods']
48
+ RubyCritic::ModulesLocator.new(analysed_module).names.must_equal ['Foo::NoMethods']
49
49
  end
50
50
  end
51
51
  end
@@ -3,14 +3,14 @@ require 'rubycritic/analysers/smells/flay'
3
3
  require 'rubycritic/core/analysed_module'
4
4
  require 'pathname'
5
5
 
6
- describe Rubycritic::Analyser::FlaySmells do
6
+ describe RubyCritic::Analyser::FlaySmells do
7
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
- Rubycritic::Analyser::FlaySmells.new(@analysed_modules).run
13
+ RubyCritic::Analyser::FlaySmells.new(@analysed_modules).run
14
14
  end
15
15
 
16
16
  it 'detects its smells' do
@@ -1,12 +1,12 @@
1
1
  require 'analysers_test_helper'
2
2
  require 'rubycritic/analysers/smells/flog'
3
3
 
4
- describe Rubycritic::Analyser::FlogSmells do
4
+ describe RubyCritic::Analyser::FlogSmells do
5
5
  context 'when analysing a complex file' do
6
6
  before do
7
7
  @analysed_module = AnalysedModuleDouble.new(path: 'test/samples/flog/smelly.rb', smells: [])
8
8
  analysed_modules = [@analysed_module]
9
- Rubycritic::Analyser::FlogSmells.new(analysed_modules).run
9
+ RubyCritic::Analyser::FlogSmells.new(analysed_modules).run
10
10
  end
11
11
 
12
12
  it 'detects its smells' do
@@ -1,13 +1,13 @@
1
1
  require 'analysers_test_helper'
2
2
  require 'rubycritic/analysers/smells/reek'
3
3
 
4
- describe Rubycritic::Analyser::ReekSmells do
4
+ describe RubyCritic::Analyser::ReekSmells do
5
5
  context 'when analysing a smelly file' do
6
6
  before do
7
7
  pathname = Pathname.new('test/samples/reek/smelly.rb')
8
8
  @analysed_module = AnalysedModuleDouble.new(pathname: pathname, smells: [])
9
9
  analysed_modules = [@analysed_module]
10
- Rubycritic::Analyser::ReekSmells.new(analysed_modules).run
10
+ RubyCritic::Analyser::ReekSmells.new(analysed_modules).run
11
11
  end
12
12
 
13
13
  it 'detects its smells' do
@@ -1,10 +1,10 @@
1
1
  require 'test_helper'
2
2
  require 'rubycritic/browser'
3
3
 
4
- describe Rubycritic::Browser do
4
+ describe RubyCritic::Browser do
5
5
  before do
6
6
  @report_path = 'tmp/rubycritic/overview.html'
7
- @browser = Rubycritic::Browser.new @report_path
7
+ @browser = RubyCritic::Browser.new @report_path
8
8
  end
9
9
 
10
10
  describe '#open' do
@@ -2,15 +2,15 @@ require 'test_helper'
2
2
  require 'rubycritic/commands/status_reporter'
3
3
  require 'rubycritic/cli/options'
4
4
 
5
- describe Rubycritic::Command::StatusReporter do
6
- let(:success_status) { Rubycritic::Command::StatusReporter::SUCCESS }
7
- let(:score_below_minimum) { Rubycritic::Command::StatusReporter::SCORE_BELOW_MINIMUM }
5
+ describe RubyCritic::Command::StatusReporter do
6
+ let(:success_status) { RubyCritic::Command::StatusReporter::SUCCESS }
7
+ let(:score_below_minimum) { RubyCritic::Command::StatusReporter::SCORE_BELOW_MINIMUM }
8
8
 
9
9
  describe 'with default options' do
10
10
  before do
11
- @options = Rubycritic::Cli::Options.new([])
11
+ @options = RubyCritic::Cli::Options.new([])
12
12
  @options.parse
13
- @reporter = Rubycritic::Command::StatusReporter.new(@options.to_h)
13
+ @reporter = RubyCritic::Command::StatusReporter.new(@options.to_h)
14
14
  end
15
15
 
16
16
  it 'has a default' do
@@ -33,9 +33,9 @@ describe Rubycritic::Command::StatusReporter do
33
33
 
34
34
  describe 'with minimum-score option' do
35
35
  before do
36
- @options = Rubycritic::Cli::Options.new(['-s', '99'])
36
+ @options = RubyCritic::Cli::Options.new(['-s', '99'])
37
37
  @options.parse
38
- @reporter = Rubycritic::Command::StatusReporter.new(@options.to_h)
38
+ @reporter = RubyCritic::Command::StatusReporter.new(@options.to_h)
39
39
  end
40
40
 
41
41
  it 'has a default' do