reek 3.0.4 → 3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +6 -0
  3. data/README.md +41 -20
  4. data/features/configuration_files/directory_specific_directives.feature +280 -0
  5. data/features/configuration_files/masking_smells.feature +0 -14
  6. data/features/step_definitions/sample_file_steps.rb +2 -2
  7. data/lib/reek/ast/sexp_extensions.rb +72 -60
  8. data/lib/reek/cli/application.rb +2 -5
  9. data/lib/reek/cli/reek_command.rb +1 -1
  10. data/lib/reek/configuration/app_configuration.rb +115 -61
  11. data/lib/reek/configuration/configuration_file_finder.rb +19 -0
  12. data/lib/reek/context/code_context.rb +102 -29
  13. data/lib/reek/context/method_context.rb +11 -48
  14. data/lib/reek/context/module_context.rb +2 -6
  15. data/lib/reek/context/root_context.rb +7 -14
  16. data/lib/reek/examiner.rb +15 -10
  17. data/lib/reek/report/report.rb +5 -4
  18. data/lib/reek/smells/boolean_parameter.rb +1 -1
  19. data/lib/reek/smells/duplicate_method_call.rb +1 -5
  20. data/lib/reek/smells/irresponsible_module.rb +2 -2
  21. data/lib/reek/smells/smell_repository.rb +30 -16
  22. data/lib/reek/smells/utility_function.rb +1 -1
  23. data/lib/reek/source/source_code.rb +10 -6
  24. data/lib/reek/source/source_locator.rb +27 -26
  25. data/lib/reek/spec.rb +8 -6
  26. data/lib/reek/spec/should_reek.rb +6 -2
  27. data/lib/reek/spec/should_reek_of.rb +5 -2
  28. data/lib/reek/spec/should_reek_only_of.rb +1 -1
  29. data/lib/reek/tree_walker.rb +49 -21
  30. data/lib/reek/version.rb +1 -1
  31. data/spec/reek/ast/sexp_extensions_spec.rb +4 -12
  32. data/spec/reek/configuration/app_configuration_spec.rb +80 -52
  33. data/spec/reek/configuration/configuration_file_finder_spec.rb +27 -15
  34. data/spec/reek/context/code_context_spec.rb +66 -17
  35. data/spec/reek/context/method_context_spec.rb +66 -64
  36. data/spec/reek/context/root_context_spec.rb +3 -1
  37. data/spec/reek/context/singleton_method_context_spec.rb +1 -2
  38. data/spec/reek/examiner_spec.rb +5 -8
  39. data/spec/reek/report/xml_report_spec.rb +3 -2
  40. data/spec/reek/smells/attribute_spec.rb +12 -17
  41. data/spec/reek/smells/duplicate_method_call_spec.rb +17 -25
  42. data/spec/reek/smells/feature_envy_spec.rb +4 -5
  43. data/spec/reek/smells/irresponsible_module_spec.rb +43 -0
  44. data/spec/reek/smells/nested_iterators_spec.rb +12 -26
  45. data/spec/reek/smells/too_many_statements_spec.rb +2 -210
  46. data/spec/reek/smells/utility_function_spec.rb +49 -5
  47. data/spec/reek/source/source_locator_spec.rb +39 -43
  48. data/spec/reek/spec/should_reek_of_spec.rb +3 -2
  49. data/spec/reek/spec/should_reek_spec.rb +25 -17
  50. data/spec/reek/tree_walker_spec.rb +214 -23
  51. data/spec/samples/configuration/full_configuration.reek +9 -0
  52. data/spec/spec_helper.rb +10 -10
  53. metadata +4 -3
  54. data/features/configuration_files/overrides_defaults.feature +0 -15
@@ -0,0 +1,9 @@
1
+ ---
2
+ IrresponsibleModule:
3
+ enabled: false
4
+ "spec/samples/three_clean_files/":
5
+ UtilityFunction:
6
+ enabled: false
7
+ exclude_paths:
8
+ - "spec/samples/two_smelly_files/"
9
+ - "spec/samples/source_with_non_ruby_files/"
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
+ require 'pathname'
1
2
  require_relative '../lib/reek/spec'
2
3
  require_relative '../lib/reek/ast/ast_node_class_map'
3
4
  require_relative '../lib/reek/configuration/app_configuration'
5
+ require 'ostruct'
4
6
 
5
7
  Reek::CLI::Silencer.silently do
6
8
  require 'factory_girl'
@@ -16,22 +18,20 @@ end
16
18
 
17
19
  FactoryGirl.find_definitions
18
20
 
19
- SAMPLES_DIR = 'spec/samples'
21
+ SAMPLES_PATH = Pathname.new("#{__dir__}/samples").relative_path_from(Pathname.pwd)
20
22
 
21
23
  # Simple helpers for our specs.
22
24
  module Helpers
23
- def with_test_config(config)
24
- if config.is_a? String
25
- Reek::Configuration::AppConfiguration.load_from_file(config)
25
+ def test_configuration_for(config)
26
+ if config.is_a? Pathname
27
+ configuration = Reek::Configuration::AppConfiguration.new OpenStruct.new(config_file: config)
26
28
  elsif config.is_a? Hash
27
- Reek::Configuration::AppConfiguration.class_eval do
28
- @configuration = config
29
- end
29
+ configuration = Reek::Configuration::AppConfiguration.new
30
+ configuration.instance_variable_set :@default_directive, config
30
31
  else
31
- raise "Unknown config given in `with_test_config`: #{config.inspect}"
32
+ raise "Unknown config given in `test_configuration_for`: #{config.inspect}"
32
33
  end
33
- yield if block_given?
34
- Reek::Configuration::AppConfiguration.reset
34
+ configuration
35
35
  end
36
36
 
37
37
  # :reek:UncommunicativeMethodName
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reek
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: '3.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rutherford
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-07-10 00:00:00.000000000 Z
13
+ date: 2015-07-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parser
@@ -251,8 +251,8 @@ files:
251
251
  - features/command_line_interface/smell_selection.feature
252
252
  - features/command_line_interface/smells_count.feature
253
253
  - features/command_line_interface/stdin.feature
254
+ - features/configuration_files/directory_specific_directives.feature
254
255
  - features/configuration_files/masking_smells.feature
255
- - features/configuration_files/overrides_defaults.feature
256
256
  - features/configuration_loading.feature
257
257
  - features/programmatic_access.feature
258
258
  - features/rake_task/rake_task.feature
@@ -406,6 +406,7 @@ files:
406
406
  - spec/samples/clean_due_to_masking/dirty_one.rb
407
407
  - spec/samples/clean_due_to_masking/dirty_two.rb
408
408
  - spec/samples/clean_due_to_masking/masked.reek
409
+ - spec/samples/configuration/full_configuration.reek
409
410
  - spec/samples/configuration/simple_configuration.reek
410
411
  - spec/samples/configuration/with_excluded_paths.reek
411
412
  - spec/samples/exceptions.reek
@@ -1,15 +0,0 @@
1
- Feature: Overriding current rules by specifying new configuration values
2
- In order to customize Reek to suit my needs
3
- As a developer
4
- I want to be able to override the default configuration values
5
-
6
- Scenario: List of configuration values is overridden by a lower configuration file
7
- Given a file with smelly variable names called 'camel_case.rb'
8
- And a configuration file allowing camel case variables
9
- When I run reek camel_case.rb
10
- Then the exit status indicates smells
11
- And it reports:
12
- """
13
- camel_case.rb -- 1 warning:
14
- [9]:CamelCase#initialize has the variable name 'x1' (UncommunicativeVariableName)
15
- """