reek 4.6.1 → 4.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -0
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +2 -2
  5. data/README.md +3 -2
  6. data/bin/code_climate_reek +1 -0
  7. data/bin/reek +1 -0
  8. data/lib/reek.rb +1 -0
  9. data/lib/reek/ast/ast_node_class_map.rb +1 -0
  10. data/lib/reek/ast/builder.rb +16 -0
  11. data/lib/reek/ast/node.rb +1 -0
  12. data/lib/reek/ast/object_refs.rb +1 -0
  13. data/lib/reek/ast/reference_collector.rb +1 -0
  14. data/lib/reek/ast/sexp_extensions.rb +1 -0
  15. data/lib/reek/ast/sexp_extensions/arguments.rb +1 -0
  16. data/lib/reek/ast/sexp_extensions/attribute_assignments.rb +1 -0
  17. data/lib/reek/ast/sexp_extensions/block.rb +1 -0
  18. data/lib/reek/ast/sexp_extensions/case.rb +1 -0
  19. data/lib/reek/ast/sexp_extensions/constant.rb +1 -0
  20. data/lib/reek/ast/sexp_extensions/if.rb +1 -0
  21. data/lib/reek/ast/sexp_extensions/lambda.rb +1 -0
  22. data/lib/reek/ast/sexp_extensions/literal.rb +1 -0
  23. data/lib/reek/ast/sexp_extensions/logical_operators.rb +1 -0
  24. data/lib/reek/ast/sexp_extensions/methods.rb +1 -0
  25. data/lib/reek/ast/sexp_extensions/module.rb +1 -0
  26. data/lib/reek/ast/sexp_extensions/nested_assignables.rb +1 -0
  27. data/lib/reek/ast/sexp_extensions/self.rb +1 -0
  28. data/lib/reek/ast/sexp_extensions/send.rb +1 -0
  29. data/lib/reek/ast/sexp_extensions/super.rb +1 -0
  30. data/lib/reek/ast/sexp_extensions/symbols.rb +1 -0
  31. data/lib/reek/ast/sexp_extensions/variables.rb +1 -0
  32. data/lib/reek/ast/sexp_extensions/when.rb +1 -0
  33. data/lib/reek/ast/sexp_extensions/yield.rb +1 -0
  34. data/lib/reek/cli/application.rb +1 -0
  35. data/lib/reek/cli/command/base_command.rb +1 -0
  36. data/lib/reek/cli/command/report_command.rb +1 -0
  37. data/lib/reek/cli/command/todo_list_command.rb +1 -0
  38. data/lib/reek/cli/options.rb +1 -0
  39. data/lib/reek/cli/silencer.rb +1 -0
  40. data/lib/reek/cli/status.rb +1 -0
  41. data/lib/reek/configuration/app_configuration.rb +1 -0
  42. data/lib/reek/configuration/configuration_file_finder.rb +1 -0
  43. data/lib/reek/configuration/configuration_validator.rb +1 -0
  44. data/lib/reek/configuration/default_directive.rb +1 -0
  45. data/lib/reek/configuration/directory_directives.rb +1 -0
  46. data/lib/reek/configuration/excluded_paths.rb +1 -0
  47. data/lib/reek/context/attribute_context.rb +1 -0
  48. data/lib/reek/context/class_context.rb +1 -0
  49. data/lib/reek/context/code_context.rb +2 -1
  50. data/lib/reek/context/ghost_context.rb +1 -0
  51. data/lib/reek/context/method_context.rb +5 -4
  52. data/lib/reek/context/module_context.rb +1 -0
  53. data/lib/reek/context/root_context.rb +1 -0
  54. data/lib/reek/context/send_context.rb +1 -0
  55. data/lib/reek/context/singleton_attribute_context.rb +1 -0
  56. data/lib/reek/context/singleton_method_context.rb +1 -0
  57. data/lib/reek/context/statement_counter.rb +1 -0
  58. data/lib/reek/context/visibility_tracker.rb +1 -0
  59. data/lib/reek/context_builder.rb +1 -0
  60. data/lib/reek/detector_repository.rb +1 -0
  61. data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +1 -0
  62. data/lib/reek/errors/bad_detector_in_comment_error.rb +1 -0
  63. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +1 -0
  64. data/lib/reek/errors/incomprehensible_source_error.rb +1 -0
  65. data/lib/reek/errors/parse_error.rb +1 -0
  66. data/lib/reek/examiner.rb +1 -0
  67. data/lib/reek/logging_error_handler.rb +1 -0
  68. data/lib/reek/report.rb +1 -0
  69. data/lib/reek/report/base_report.rb +1 -0
  70. data/lib/reek/report/code_climate.rb +1 -0
  71. data/lib/reek/report/code_climate/code_climate_configuration.rb +1 -0
  72. data/lib/reek/report/code_climate/code_climate_fingerprint.rb +1 -0
  73. data/lib/reek/report/code_climate/code_climate_formatter.rb +1 -0
  74. data/lib/reek/report/code_climate/code_climate_report.rb +1 -0
  75. data/lib/reek/report/formatter.rb +1 -0
  76. data/lib/reek/report/formatter/heading_formatter.rb +1 -0
  77. data/lib/reek/report/formatter/location_formatter.rb +1 -0
  78. data/lib/reek/report/formatter/progress_formatter.rb +1 -0
  79. data/lib/reek/report/formatter/wiki_link_warning_formatter.rb +1 -0
  80. data/lib/reek/report/html_report.rb +1 -0
  81. data/lib/reek/report/json_report.rb +1 -0
  82. data/lib/reek/report/text_report.rb +1 -0
  83. data/lib/reek/report/xml_report.rb +1 -0
  84. data/lib/reek/report/yaml_report.rb +1 -0
  85. data/lib/reek/smell_configuration.rb +1 -0
  86. data/lib/reek/smell_detectors.rb +1 -0
  87. data/lib/reek/smell_detectors/attribute.rb +1 -0
  88. data/lib/reek/smell_detectors/base_detector.rb +1 -0
  89. data/lib/reek/smell_detectors/boolean_parameter.rb +1 -0
  90. data/lib/reek/smell_detectors/class_variable.rb +1 -0
  91. data/lib/reek/smell_detectors/control_parameter.rb +1 -0
  92. data/lib/reek/smell_detectors/data_clump.rb +1 -0
  93. data/lib/reek/smell_detectors/duplicate_method_call.rb +1 -0
  94. data/lib/reek/smell_detectors/feature_envy.rb +1 -0
  95. data/lib/reek/smell_detectors/instance_variable_assumption.rb +1 -0
  96. data/lib/reek/smell_detectors/irresponsible_module.rb +1 -0
  97. data/lib/reek/smell_detectors/long_parameter_list.rb +1 -0
  98. data/lib/reek/smell_detectors/long_yield_list.rb +1 -0
  99. data/lib/reek/smell_detectors/manual_dispatch.rb +1 -0
  100. data/lib/reek/smell_detectors/module_initialize.rb +1 -0
  101. data/lib/reek/smell_detectors/nested_iterators.rb +1 -0
  102. data/lib/reek/smell_detectors/nil_check.rb +1 -0
  103. data/lib/reek/smell_detectors/prima_donna_method.rb +1 -0
  104. data/lib/reek/smell_detectors/repeated_conditional.rb +1 -0
  105. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +1 -0
  106. data/lib/reek/smell_detectors/too_many_constants.rb +1 -0
  107. data/lib/reek/smell_detectors/too_many_instance_variables.rb +1 -0
  108. data/lib/reek/smell_detectors/too_many_methods.rb +1 -0
  109. data/lib/reek/smell_detectors/too_many_statements.rb +1 -0
  110. data/lib/reek/smell_detectors/uncommunicative_method_name.rb +1 -0
  111. data/lib/reek/smell_detectors/uncommunicative_module_name.rb +1 -0
  112. data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +1 -0
  113. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +1 -0
  114. data/lib/reek/smell_detectors/unused_parameters.rb +1 -0
  115. data/lib/reek/smell_detectors/unused_private_method.rb +3 -2
  116. data/lib/reek/smell_detectors/utility_function.rb +1 -0
  117. data/lib/reek/smell_warning.rb +1 -0
  118. data/lib/reek/source/source_code.rb +17 -3
  119. data/lib/reek/source/source_locator.rb +1 -0
  120. data/lib/reek/spec.rb +1 -0
  121. data/lib/reek/spec/should_reek.rb +1 -0
  122. data/lib/reek/spec/should_reek_of.rb +1 -0
  123. data/lib/reek/spec/should_reek_only_of.rb +1 -0
  124. data/lib/reek/spec/smell_matcher.rb +2 -1
  125. data/lib/reek/tree_dresser.rb +1 -0
  126. data/lib/reek/version.rb +2 -1
  127. data/reek.gemspec +2 -1
  128. data/spec/reek/ast/sexp_extensions_spec.rb +1 -0
  129. data/spec/reek/context/statement_counter_spec.rb +1 -0
  130. data/spec/reek/examiner_spec.rb +1 -0
  131. data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +2 -0
  132. data/spec/reek/report/code_climate/code_climate_report_spec.rb +22 -22
  133. data/spec/reek/report/yaml_report_spec.rb +32 -32
  134. data/spec/reek/source/source_code_spec.rb +8 -1
  135. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a703ee92e2eee612e747e83dd8f7262cc889a347
4
- data.tar.gz: 2cd0f17e74826fabc001c770a96f7cc24545ced3
3
+ metadata.gz: 621c25e4d095d1164a97aea57967dcf79f1961ec
4
+ data.tar.gz: 4e9dbb2eee9bec1ac8616811b1895631206cd394
5
5
  SHA512:
6
- metadata.gz: 3bc0fe4ede8578d81c431bda322171cc240daaa3502da110fe98ecd6cd927fd7d336b83a813df6dff2acfd7d685fc70248e490f51cce4ede9ade528b80ff0e34
7
- data.tar.gz: 8387daed0291caee16f71bd78c9dd3477d1cad1220e7998618039d937b5c017f5ca5fc95182268e7793d4ea975ac88a50a4d8fbd1b494fd02ad32a4c8f908095
6
+ metadata.gz: d5c4bf0e5c8f2b344b5bec3c386599e1a2d2eadc6e70c484146d771190fcc6fba24986a7747654962caaac5f27c625a49d2f11a5f9f0c8f375b34b309945178b
7
+ data.tar.gz: a98dab6abcd0ffdc95695ba0883ca078ae9fa3b50d0493bf1d89f3677947d7056d5a3e7529eb9611ad5a50d1ab1efb682f2611247cd0d7225e3d4fcc12396ccb
@@ -8,6 +8,10 @@ AllCops:
8
8
  - 'vendor/**/*'
9
9
  TargetRubyVersion: 2.1
10
10
 
11
+ # Assume the programmer knows how bracketed block syntax works
12
+ Lint/AmbiguousBlockAssociation:
13
+ Enabled: false
14
+
11
15
  Lint/HandleExceptions:
12
16
  Exclude:
13
17
  - 'spec/reek/configuration/configuration_file_finder_spec.rb'
@@ -106,6 +110,10 @@ Style/FrozenStringLiteralComment:
106
110
  - 'lib/**/*'
107
111
  EnforcedStyle: always
108
112
 
113
+ # Use active_support's strip_heredoc to indent heredocs
114
+ Style/IndentHeredoc:
115
+ EnforcedStyle: active_support
116
+
109
117
  # Allow multiline block chains
110
118
  Style/MultilineBlockChain:
111
119
  Enabled: false
@@ -126,6 +134,14 @@ Style/MultilineOperationIndentation:
126
134
  Style/ParallelAssignment:
127
135
  Enabled: false
128
136
 
137
+ Style/PercentLiteralDelimiters:
138
+ PreferredDelimiters:
139
+ default: ()
140
+ '%W': ()
141
+ '%I': ()
142
+ '%w': ()
143
+ '%i': ()
144
+
129
145
  # Allow Perl-style references to regex matches
130
146
  Style/PerlBackrefs:
131
147
  Enabled: false
@@ -134,6 +150,10 @@ Style/PerlBackrefs:
134
150
  Style/SingleLineMethods:
135
151
  Enabled: false
136
152
 
153
+ # Prefer symbols to look like symbols
154
+ Style/SymbolArray:
155
+ EnforcedStyle: brackets
156
+
137
157
  # Allow small arrays of words with quotes
138
158
  Style/WordArray:
139
159
  MinSize: 4
@@ -1,5 +1,10 @@
1
1
  # Change log
2
2
 
3
+ ## 4.6.2 (2017-04-27)
4
+
5
+ * (pocke) Prevent from breaking on a string with escape sequence incompatible with UTF-8
6
+ * (pocke) Use Ruby 2.4 parser for parsing code
7
+
3
8
  ## 4.6.1 (2017-04-05)
4
9
 
5
10
  * (IanWhitney) Properly handle absolute paths.
data/Gemfile CHANGED
@@ -16,8 +16,8 @@ group :development do
16
16
  gem 'yard', '~> 0.9.5'
17
17
 
18
18
  if RUBY_VERSION >= '2.3'
19
- gem 'rubocop', '~> 0.47.1'
20
- gem 'rubocop-rspec', '~> 1.13.0'
19
+ gem 'rubocop', '~> 0.48.1'
20
+ gem 'rubocop-rspec', '~> 1.15.0'
21
21
  end
22
22
 
23
23
  platforms :mri do
data/README.md CHANGED
@@ -100,6 +100,7 @@ Reek is officially running on the following MRI rubies:
100
100
  - 2.1
101
101
  - 2.2
102
102
  - 2.3
103
+ - 2.4
103
104
 
104
105
  Other rubies like Rubinius or JRuby are not officially supported but should work as well.
105
106
 
@@ -475,7 +476,7 @@ Or just run the whole test suite:
475
476
  bundle exec rake
476
477
  ```
477
478
 
478
- This will run the RSpec tests, RuboCop and Reek itself.
479
+ This will run the tests (RSpec and Cucumber), RuboCop and Reek itself.
479
480
 
480
481
  You can also run:
481
482
 
@@ -484,7 +485,7 @@ bundle exec rake ci
484
485
  ```
485
486
 
486
487
  This will run everything the default task runs and also
487
- our Cucumber features and [Ataru](https://github.com/CodePadawans/ataru). This is the task that we run on
488
+ [Ataru](https://github.com/CodePadawans/ataru). This is the task that we run on
488
489
  Travis as well and that determines if your pull request is green or red.
489
490
 
490
491
  Another useful Rake task is the `console` task. This will throw you right into an environment where you can play around with Reeks modules and classes:
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  #
4
5
  # Wrapper for the CodeClimate integration.
5
6
 
data/bin/reek CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  #
4
5
  # Reek examines Ruby source code for smells.
5
6
  # Visit https://wiki.github.com/troessner/reek for docs etc.
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Reek's core functionality
4
5
  #
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'node'
3
4
  require_relative 'sexp_extensions'
4
5
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Reek
4
+ module AST
5
+ #
6
+ # An AST Builder for ruby parser.
7
+ #
8
+ class Builder < ::Parser::Builders::Default
9
+ # This is a work around for parsing ruby code that has a string with invliad sequence as UTF-8.
10
+ # See. https://github.com/whitequark/parser/issues/283
11
+ def string_value(token)
12
+ value(token)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '../cli/silencer'
3
4
 
4
5
  Reek::CLI::Silencer.silently do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  # Represents functionality related to an Abstract Syntax Tree.
4
5
  module AST
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  #
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'reference_collector'
3
4
 
4
5
  require_relative 'sexp_extensions/arguments'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module AST
4
5
  module SexpExtensions
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'options'
3
4
  require_relative 'status'
4
5
  require_relative '../configuration/app_configuration'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module CLI
4
5
  module Command
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'base_command'
3
4
  require_relative '../../examiner'
4
5
  require_relative '../../logging_error_handler'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'base_command'
3
4
  require_relative '../../examiner'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'optparse'
3
4
  require 'rainbow'
4
5
  require_relative '../version'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'stringio'
3
4
 
4
5
  module Reek
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module CLI
4
5
  module Status
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'pathname'
3
4
  require_relative './configuration_file_finder'
4
5
  require_relative './configuration_validator'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'pathname'
3
4
 
4
5
  module Reek
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module Configuration
4
5
  #
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Reek
3
4
  module Configuration
4
5
  #
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative './configuration_validator'
3
4
 
4
5
  module Reek
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative './configuration_validator'
3
4
 
4
5
  module Reek
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'code_context'
3
4
 
4
5
  module Reek
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'module_context'
3
4
 
4
5
  module Reek
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '../code_comment'
3
4
  require_relative '../ast/object_refs'
4
5
  require_relative 'statement_counter'
@@ -19,7 +20,7 @@ module Reek
19
20
  include Enumerable
20
21
  extend Forwardable
21
22
  delegate each_node: :exp
22
- delegate %i(name type) => :exp
23
+ delegate [:name, :type] => :exp
23
24
 
24
25
  attr_reader :children, :parent, :exp, :statement_counter
25
26
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'code_context'
3
4
  require_relative 'singleton_method_context'
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative 'code_context'
3
4
 
4
5
  module Reek
@@ -40,10 +41,10 @@ module Reek
40
41
 
41
42
  # :reek:FeatureEnvy
42
43
  def unused_params
43
- exp.arguments.select do |param|
44
- next if param.anonymous_splat?
45
- next if param.marked_unused?
46
- !uses_param? param.plain_name
44
+ exp.arguments.reject do |param|
45
+ param.anonymous_splat? ||
46
+ param.marked_unused? ||
47
+ uses_param?(param.plain_name)
47
48
  end
48
49
  end
49
50