tailor 0.1.5 → 1.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/.gitignore +9 -1
  2. data/.rspec +2 -1
  3. data/.tailor +6 -0
  4. data/Gemfile.lock +47 -78
  5. data/{ChangeLog.rdoc → History.rdoc} +0 -0
  6. data/README.rdoc +157 -24
  7. data/Rakefile +0 -9
  8. data/bin/tailor +16 -69
  9. data/features/configurable.feature +78 -0
  10. data/features/horizontal_spacing.feature +262 -0
  11. data/features/indentation.feature +17 -21
  12. data/features/indentation/bad_files_with_no_trailing_newline.feature +90 -0
  13. data/features/indentation/good_files_with_no_trailing_newline.feature +206 -0
  14. data/features/name_detection.feature +72 -0
  15. data/features/step_definitions/indentation_steps.rb +10 -133
  16. data/features/support/env.rb +7 -15
  17. data/features/support/file_cases/horizontal_spacing_cases.rb +265 -0
  18. data/features/support/file_cases/indentation_cases.rb +972 -0
  19. data/features/support/file_cases/naming_cases.rb +52 -0
  20. data/features/support/file_cases/vertical_spacing_cases.rb +70 -0
  21. data/features/support/hooks.rb +8 -0
  22. data/features/support/{1_file_with_bad_operator_spacing → legacy}/bad_op_spacing.rb +0 -0
  23. data/features/support/{1_file_with_bad_ternary_colon_spacing → legacy}/bad_ternary_colon_spacing.rb +0 -0
  24. data/features/support/{1_long_file_with_indentation/my_project.rb → legacy/long_file_with_indentation.rb} +1 -1
  25. data/features/support/world.rb +14 -0
  26. data/features/vertical_spacing.feature +114 -0
  27. data/lib/ext/string_ext.rb +5 -0
  28. data/lib/tailor.rb +6 -252
  29. data/lib/tailor/cli.rb +49 -0
  30. data/lib/tailor/cli/options.rb +251 -0
  31. data/lib/tailor/composite_observable.rb +56 -0
  32. data/lib/tailor/configuration.rb +263 -0
  33. data/lib/tailor/critic.rb +162 -0
  34. data/lib/tailor/formatters/text.rb +126 -0
  35. data/lib/tailor/lexed_line.rb +246 -0
  36. data/lib/tailor/lexer.rb +428 -0
  37. data/lib/tailor/lexer/token.rb +103 -0
  38. data/lib/tailor/lexer_constants.rb +75 -0
  39. data/lib/tailor/logger.rb +28 -0
  40. data/lib/tailor/problem.rb +100 -0
  41. data/lib/tailor/reporter.rb +48 -0
  42. data/lib/tailor/ruler.rb +39 -0
  43. data/lib/tailor/rulers.rb +7 -0
  44. data/lib/tailor/rulers/allow_camel_case_methods_ruler.rb +30 -0
  45. data/lib/tailor/rulers/allow_hard_tabs_ruler.rb +22 -0
  46. data/lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb +32 -0
  47. data/lib/tailor/rulers/allow_trailing_line_spaces_ruler.rb +33 -0
  48. data/lib/tailor/rulers/indentation_spaces_ruler.rb +199 -0
  49. data/lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb +362 -0
  50. data/lib/tailor/rulers/max_code_lines_in_class_ruler.rb +84 -0
  51. data/lib/tailor/rulers/max_code_lines_in_method_ruler.rb +84 -0
  52. data/lib/tailor/rulers/max_line_length_ruler.rb +31 -0
  53. data/lib/tailor/rulers/spaces_after_comma_ruler.rb +83 -0
  54. data/lib/tailor/rulers/spaces_after_lbrace_ruler.rb +114 -0
  55. data/lib/tailor/rulers/spaces_after_lbracket_ruler.rb +123 -0
  56. data/lib/tailor/rulers/spaces_after_lparen_ruler.rb +116 -0
  57. data/lib/tailor/rulers/spaces_before_comma_ruler.rb +67 -0
  58. data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +93 -0
  59. data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +98 -0
  60. data/lib/tailor/rulers/spaces_before_rbracket_ruler.rb +70 -0
  61. data/lib/tailor/rulers/spaces_before_rparen_ruler.rb +70 -0
  62. data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +94 -0
  63. data/lib/tailor/rulers/trailing_newlines_ruler.rb +36 -0
  64. data/lib/tailor/runtime_error.rb +3 -0
  65. data/lib/tailor/tailorrc.erb +88 -0
  66. data/lib/tailor/version.rb +2 -2
  67. data/spec/spec_helper.rb +7 -5
  68. data/spec/tailor/cli_spec.rb +94 -0
  69. data/spec/tailor/configuration_spec.rb +147 -0
  70. data/spec/tailor/critic_spec.rb +63 -0
  71. data/spec/tailor/lexed_line_spec.rb +569 -0
  72. data/spec/tailor/lexer/token_spec.rb +46 -0
  73. data/spec/tailor/lexer_spec.rb +181 -0
  74. data/spec/tailor/options_spec.rb +6 -0
  75. data/spec/tailor/problem_spec.rb +74 -0
  76. data/spec/tailor/reporter_spec.rb +53 -0
  77. data/spec/tailor/ruler_spec.rb +56 -0
  78. data/spec/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +454 -0
  79. data/spec/tailor/rulers/indentation_spaces_ruler_spec.rb +128 -0
  80. data/spec/tailor/rulers/spaces_after_comma_spec.rb +31 -0
  81. data/spec/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +145 -0
  82. data/spec/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +63 -0
  83. data/spec/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +63 -0
  84. data/spec/tailor/rulers_spec.rb +9 -0
  85. data/spec/tailor/version_spec.rb +6 -0
  86. data/spec/tailor_spec.rb +9 -21
  87. data/tailor.gemspec +22 -35
  88. data/tasks/features.rake +7 -0
  89. data/tasks/roodi.rake +9 -0
  90. data/tasks/roodi_config.yaml +14 -0
  91. data/tasks/spec.rake +16 -0
  92. data/tasks/yard.rake +14 -0
  93. metadata +224 -77
  94. data/features/case_checking.feature +0 -38
  95. data/features/spacing.feature +0 -97
  96. data/features/spacing/commas.feature +0 -44
  97. data/features/step_definitions/case_checking_steps.rb +0 -42
  98. data/features/step_definitions/spacing_steps.rb +0 -156
  99. data/features/support/1_file_with_bad_comma_spacing/bad_comma_spacing.rb +0 -43
  100. data/features/support/1_file_with_bad_curly_brace_spacing/bad_curly_brace_spacing.rb +0 -60
  101. data/features/support/1_file_with_bad_parenthesis/bad_parenthesis.rb +0 -4
  102. data/features/support/1_file_with_bad_square_brackets/bad_square_brackets.rb +0 -62
  103. data/features/support/1_file_with_camel_case_class/camel_case_class.rb +0 -5
  104. data/features/support/1_file_with_camel_case_method/camel_case_method.rb +0 -3
  105. data/features/support/1_file_with_hard_tabs/hard_tab.rb +0 -3
  106. data/features/support/1_file_with_long_lines/long_lines.rb +0 -5
  107. data/features/support/1_file_with_snake_case_class/snake_case_class.rb +0 -5
  108. data/features/support/1_file_with_snake_case_method/snake_case_method.rb +0 -3
  109. data/features/support/1_file_with_trailing_whitespace/trailing_whitespace.rb +0 -5
  110. data/features/support/1_good_simple_file/simple_project.rb +0 -5
  111. data/features/support/common.rb +0 -102
  112. data/features/support/matchers.rb +0 -11
  113. data/lib/tailor/file_line.rb +0 -220
  114. data/lib/tailor/indentation.rb +0 -245
  115. data/lib/tailor/spacing.rb +0 -237
  116. data/spec/file_line_spec.rb +0 -70
  117. data/spec/indentation_spec.rb +0 -259
  118. data/spec/spacing/colon_spacing_spec.rb +0 -71
  119. data/spec/spacing/comma_spacing_spec.rb +0 -159
  120. data/spec/spacing/curly_brace_spacing_spec.rb +0 -257
  121. data/spec/spacing/parentheses_spacing_spec.rb +0 -28
  122. data/spec/spacing/square_bracket_spacing_spec.rb +0 -116
  123. data/spec/spacing_spec.rb +0 -167
  124. data/tasks/metrics.rake +0 -23
@@ -0,0 +1,52 @@
1
+ NAMING_OK = {}
2
+ NAMING_1 = {}
3
+
4
+ NAMING_OK[:single_word_method] =
5
+ %Q{def thing
6
+ end}
7
+
8
+ NAMING_OK[:two_word_method] =
9
+ %Q{def thing_one
10
+ end}
11
+
12
+ NAMING_1[:one_caps_camel_case_method] =
13
+ %Q{def thingOne
14
+ end}
15
+
16
+ NAMING_1[:one_caps_camel_case_method_trailing_comment] =
17
+ %Q{def thingOne # comment
18
+ end}
19
+
20
+ #-------------------------------------------------------------------------------
21
+ NAMING_OK[:single_word_class] =
22
+ %Q{class Thing
23
+ end}
24
+
25
+ NAMING_OK[:single_word_module] =
26
+ %Q{module Thing
27
+ end}
28
+
29
+ NAMING_OK[:two_word_class] =
30
+ %Q{class ThingOne
31
+ end}
32
+
33
+ NAMING_OK[:two_word_module] =
34
+ %Q{module ThingOne
35
+ end}
36
+
37
+ NAMING_1[:one_screaming_snake_case_class] =
38
+ %Q{class Thing_One
39
+ end}
40
+
41
+ NAMING_1[:one_screaming_snake_module_class] =
42
+ %Q{module Thing_One
43
+ end}
44
+
45
+ NAMING_1[:two_screaming_snake_case_class] =
46
+ %Q{class Thing_One_Again
47
+ end}
48
+
49
+ NAMING_1[:two_screaming_snake_module_class] =
50
+ %Q{module Thing_One_Again
51
+ end}
52
+
@@ -0,0 +1,70 @@
1
+ V_SPACING_OK = {}
2
+ V_SPACING_1 = {}
3
+
4
+ #-------------------------------------------------------------------------------
5
+ # Class length
6
+ #-------------------------------------------------------------------------------
7
+ V_SPACING_OK[:class_five_code_lines] =
8
+ %Q{class Party
9
+ include Clowns
10
+
11
+ def barrel_roll
12
+ end
13
+ end}
14
+
15
+ V_SPACING_OK[:embedded_class_five_code_lines] =
16
+ %Q{class Party
17
+ class Pizza
18
+ include Cheese
19
+ end
20
+ end}
21
+
22
+ V_SPACING_1[:class_too_long] =
23
+ %Q{class Party
24
+ include Clowns
25
+ include Pizza
26
+
27
+ def barrel_roll
28
+ puts "DOABARRELROLL!"
29
+ end
30
+ end}
31
+
32
+ V_SPACING_1[:parent_class_too_long] =
33
+ %Q{class Party
34
+
35
+ class Pizza
36
+ include Cheese
37
+ include Yumminess
38
+ end
39
+ end}
40
+
41
+ #-------------------------------------------------------------------------------
42
+ # Method length
43
+ #-------------------------------------------------------------------------------
44
+ V_SPACING_OK[:method_3_code_lines] =
45
+ %Q{def thing
46
+
47
+
48
+ puts 'hi'
49
+ end}
50
+
51
+ V_SPACING_OK[:embedded_method_3_code_lines] =
52
+ %Q{def outter_thing
53
+ def thing; puts 'hi'; end
54
+
55
+
56
+ end}
57
+
58
+ V_SPACING_1[:method_too_long] =
59
+ %Q{def thing
60
+ puts
61
+ puts
62
+ end}
63
+
64
+ V_SPACING_1[:parent_method_too_long] =
65
+ %Q{def thing
66
+ puts
67
+ def inner_thing; print '1'; end
68
+ puts
69
+ end}
70
+
@@ -0,0 +1,8 @@
1
+ Before do
2
+ @original_home = ENV['HOME']
3
+ ENV['HOME'] = '.'
4
+ end
5
+
6
+ After do
7
+ ENV['HOME'] = @original_home
8
+ end
@@ -1 +1,15 @@
1
+ module IndentationHelpers
1
2
 
3
+ # Used for getting the faked file contexts from the indentation_cases.rb file.
4
+ #
5
+ # @param [String] file_name The name of the fake file to get.
6
+ # @return [String]
7
+ def get_file_contents(file_name)
8
+ path_chunks = file_name.split('/')
9
+ const_name = path_chunks.first(2).each { |c| c.upcase! }.join("_")
10
+ const = Kernel.const_get(const_name)
11
+
12
+ const[path_chunks.last.to_sym]
13
+ end
14
+ end
15
+ World(IndentationHelpers)
@@ -0,0 +1,114 @@
1
+ Feature: Vertical spacing
2
+ As a Ruby developer
3
+ I want to check my Ruby files for vertical spacing
4
+
5
+ Background:
6
+ Given my configuration file ".tailor" looks like:
7
+ """
8
+ Tailor.config do |config|
9
+ config.file_set do
10
+ max_code_lines_in_class 5
11
+ max_code_lines_in_method 3
12
+ trailing_newlines 0
13
+ end
14
+ end
15
+ """
16
+
17
+ @bad_files
18
+ Scenario: Detect lack of newlines
19
+ Given a file named "not_enough_newlines.rb" with:
20
+ """
21
+ def a_method
22
+ puts 'hi'
23
+ end
24
+ """
25
+ When I run `tailor -d .`
26
+ Then the output should match /Total Problems.*1/
27
+ And the output should contain "0 trailing newlines, but should have 1"
28
+
29
+ @bad_files
30
+ Scenario: Detect too many newlines
31
+ Given a file named "too_many_newlines.rb" with:
32
+ """
33
+ def a_method
34
+ puts 'hi'
35
+ end
36
+
37
+
38
+ """
39
+ When I run `tailor -d .`
40
+ Then the output should match /Total Problems.*1/
41
+ And the output should contain "2 trailing newlines, but should have 1"
42
+
43
+ @good_files
44
+ Scenario: Doesn't report problem when meeting criteria
45
+ Given a file named "good_file.rb" with:
46
+ """
47
+ def a_method
48
+ puts 'hi'
49
+ end
50
+
51
+ """
52
+ When I run `tailor -d .`
53
+ Then the output should match /Total Problems.*0/
54
+
55
+ @good_files @class_length
56
+
57
+ @multi_line
58
+ Scenario Outline: Classes/modules with <= configured lines
59
+ Given <File> exists without a newline at the end
60
+ When I run `tailor -d -c .tailor <File>`
61
+ Then the output should match /Total Problems.*0/
62
+ And the exit status should be 0
63
+
64
+ Scenarios:
65
+ | File |
66
+ | v_spacing/ok/class_five_code_lines |
67
+ | v_spacing/ok/embedded_class_five_code_lines |
68
+
69
+ @bad_files @class_length
70
+
71
+ @multi_line
72
+ Scenario Outline: Lines with bad spacing around parens
73
+ Given <File> exists without a newline at the end
74
+ When I run `tailor -d -c .tailor <File>`
75
+ Then the output should match /Total Problems.*<Problems>/
76
+ And the output should match /position: <Position>/
77
+ And the output should match /position: <Position 2>/
78
+ And the exit status should be 1
79
+
80
+ Scenarios:
81
+ | File | Position | Position 2 | Problems |
82
+ | v_spacing/1/class_too_long | 1:0 | | 1 |
83
+ | v_spacing/1/parent_class_too_long | 1:0 | | 1 |
84
+
85
+ @good_files @method_length
86
+
87
+ @multi_line
88
+ Scenario Outline: Methods with <= configured lines
89
+ Given <File> exists without a newline at the end
90
+ When I run `tailor -d -c .tailor <File>`
91
+ Then the output should match /Total Problems.*0/
92
+ And the exit status should be 0
93
+
94
+ Scenarios:
95
+ | File |
96
+ | v_spacing/ok/method_3_code_lines |
97
+ | v_spacing/ok/embedded_method_3_code_lines |
98
+
99
+ @bad_files @method_length
100
+
101
+ @multi_line
102
+ Scenario Outline: Lines with bad spacing around parens
103
+ Given <File> exists without a newline at the end
104
+ When I run `tailor -d -c .tailor <File>`
105
+ Then the output should match /Total Problems.*<Problems>/
106
+ And the output should match /position: <Position>/
107
+ And the output should match /position: <Position 2>/
108
+ And the exit status should be 1
109
+
110
+ Scenarios:
111
+ | File | Position | Position 2 | Problems |
112
+ | v_spacing/1/method_too_long | 1:0 | | 1 |
113
+ | v_spacing/1/parent_method_too_long | 1:0 | | 1 |
114
+
@@ -0,0 +1,5 @@
1
+ require 'term/ansicolor'
2
+
3
+ class String
4
+ include Term::ANSIColor
5
+ end
@@ -1,256 +1,10 @@
1
- $:.unshift(File.dirname(__FILE__)) unless
2
- $:.include?(File.dirname(__FILE__)) ||
3
- $:.include?(File.expand_path(File.dirname(__FILE__)))
1
+ require_relative 'tailor/configuration'
4
2
 
5
- require 'fileutils'
6
- require 'pathname'
7
- require 'tailor/version'
8
- require 'tailor/file_line'
9
- require 'tailor/spacing'
3
+ class Tailor
4
+ def self.config
5
+ configuration = Tailor::Configuration.new
6
+ yield configuration if block_given?
10
7
 
11
- module Tailor
12
-
13
- # These operators should always have 1 space around them
14
- OPERATORS = {
15
- :arithmetic => ['+', '-', '*', '/', '%', '++', '--', '**'],
16
- :assignment => ['=', '+=', '-=', '*=', '/=', '%=', '*=', '**=', '|', '&=',
17
- '&&=', '>>=', '<<=', '||='],
18
- :comparison => ['==', '===', '!=', '>', '<', '>=', '<=', '<=>', '!', '~'],
19
- :gem_version => ['~>'],
20
- :logical => ['&&', '||', 'and', 'or'],
21
- :regex => ['^', '|', '!~', '=~'],
22
- :shift => ['<<', '>>'],
23
- :ternary => ['?', ':']
24
- }
25
-
26
- # These operators should never have spaces around them.
27
- NO_SPACE_AROUND_OPERATORS = {
28
- :range => ['..', '...'],
29
- :scope_resolution => ['::']
30
- }
31
-
32
- # Don't do anything about these ops; they're just here so we know not to do
33
- # anything with them.
34
- DO_NOTHING_OPS = {
35
- :elements => ['[]', '[]=']
36
- }
37
-
38
- # Check all files in a directory for style problems.
39
- #
40
- # @param [String] project_base_dir Path to a directory to recurse into and
41
- # look for problems in.
42
- # @return [Hash] Returns a hash that contains file_name => problem_count.
43
- def self.check project_base_dir
44
- # Get the list of files to process
45
- ruby_files_in_project = project_file_list(project_base_dir)
46
-
47
- files_and_problems = Hash.new
48
-
49
- # Process each file
50
- ruby_files_in_project.each do |file_name|
51
- problems = find_problems_in file_name
52
- files_and_problems[file_name] = problems
53
- end
54
-
55
- files_and_problems
56
- end
57
-
58
-
59
- # Check a single file for style problems.
60
- #
61
- # @param [String] file_name Path to a file to check style on.
62
- # @return [Hash] Returns a hash that contains file_name => problem_count.
63
- def self.check_file file_name
64
- files_and_problems = Hash.new
65
-
66
- problems = find_problems_in File.expand_path(file_name)
67
- files_and_problems[file_name] = problems
68
-
69
- files_and_problems
70
- end
71
-
72
- # Gets a list of .rb files in the project. This gets each file's absolute
73
- # path in order to alleviate any possible confusion.
74
- #
75
- # @param [String] base_dir Directory to start recursing from to look for .rb
76
- # files.
77
- # @return [Array] Sorted list of absolute file paths in the project.
78
- def self.project_file_list base_dir
79
- if File.directory? base_dir
80
- FileUtils.cd base_dir
81
- end
82
-
83
- # Get the .rb files
84
- ruby_files_in_project = Dir.glob(File.join('*', '**', '*.rb'))
85
- Dir.glob(File.join('*.rb')).each { |file| ruby_files_in_project << file }
86
-
87
- # Get the .erb files
88
- Dir.glob(File.join('*.erb')).each { |file| ruby_files_in_project << file }
89
-
90
- # Expand paths to all files in the list
91
- list_with_absolute_paths = Array.new
92
- ruby_files_in_project.each do |file|
93
- list_with_absolute_paths << File.expand_path(file)
94
- end
95
-
96
- list_with_absolute_paths.sort
97
- end
98
-
99
- # Checks a sing file for all defined styling parameters.
100
- #
101
- # @param [String] file_name Path to a file to check styling on.
102
- # @return [Number] Returns the number of errors on the file.
103
- def self.find_problems_in file_name
104
- source = File.open(file_name, 'r')
105
- file_path = Pathname.new(file_name)
106
-
107
- puts ""
108
- puts "#-------------------------------------------------------------------"
109
- puts "# Looking for bad style in:"
110
- puts "# \t'#{file_path}'"
111
- puts "#-------------------------------------------------------------------"
112
-
113
- @problem_count = 0
114
- line_number = 1
115
- =begin
116
- current_level = 0.0
117
- next_level = 0.0
118
- multi_line_next_level = 0.0
119
- multi_line = false
120
- =end
121
-
122
- source.each_line do |source_line|
123
- line = FileLine.new(source_line, file_path, line_number)
124
-
125
- =begin
126
- puts "line num: #{line_number}"
127
- if line.ends_with_comma?
128
- puts "COMMA"
129
- end
130
- if line.ends_with_backslash?
131
- puts "BACKSLASH"
132
- end
133
- if line.ends_with_operator?
134
- puts "OPERATOR"
135
- end
136
- if line.unclosed_parenthesis?
137
- puts "PARENTHESIS"
138
- end
139
-
140
- multi_line_statement = line.multi_line_statement?
141
-
142
- # If we're not in a multi-line statement, but this is the beginning of
143
- # one...
144
- if multi_line == false and multi_line_statement
145
- multi_line = true
146
- multi_line_next_level = current_level + 1.0
147
- puts ":multi-line: current = #{current_level}; next = #{next_level}" +
148
- "; multi_line_next = #{multi_line_next_level}"
149
- # If we're already in a multi-line statement...
150
- elsif multi_line == true and multi_line_statement
151
- puts ":multi-line: current = #{current_level}; next = #{next_level}" +
152
- "; multi_line_next = #{multi_line_next_level}"
153
- # Keep current_line and next_line the same
154
- elsif multi_line == true and !multi_line_statement and line.indent?
155
- #next_level -= 1.0
156
- puts ":multi-line: current = #{current_level}; next = #{next_level}" +
157
- "; multi_line_next = #{multi_line_next_level}"
158
- else
159
- multi_line = false
160
- end
161
-
162
- if line.outdent?
163
- current_level -= 1.0
164
- next_level = current_level + 1.0
165
- puts ":outdent: current = #{current_level}; next = #{next_level}" +
166
- "; multi_line_next = #{multi_line_next_level}"
167
- end
168
-
169
- if line.contains_end?
170
- current_level -= 1.0
171
- next_level = current_level
172
- puts ":end: current = #{current_level}; next = #{next_level}" +
173
- "; multi_line_next = #{multi_line_next_level}"
174
- end
175
-
176
- if multi_line == true and !multi_line_statement and line.indent?
177
- elsif line.indent?
178
- next_level = current_level + 1.0
179
- puts ":indent: current = #{current_level}; next = #{next_level}" +
180
- "; multi_line_next = #{multi_line_next_level}"
181
- end
182
-
183
- if !line.indent? and !line.outdent? and !line.contains_end?
184
- puts ":same: current = #{current_level}; next = #{next_level}" +
185
- "; multi_line_next = #{multi_line_next_level}"
186
- end
187
-
188
- #if line.indent? or line.outdent? or line.contains_end?
189
- if line.at_improper_level? current_level
190
- @problem_count += 1
191
- end
192
- #end
193
-
194
- # If this is the last line of the multi-line statement...
195
- if multi_line == true and multi_line_statement
196
- puts "Assigning current (#{current_level}) to multi_next (#{multi_line_next_level})"
197
- current_level = multi_line_next_level
198
- elsif multi_line == true and !multi_line_statement
199
- multi_line = false
200
- puts "Assigning current (#{current_level}) = next (#{next_level}) "
201
- current_level = next_level
202
- #elsif multi_line == false
203
- else
204
- puts "Assigning current (#{current_level}) = next (#{next_level}) "
205
- current_level = next_level
206
- end
207
- =end
208
- @problem_count += line.spacing_problems
209
-
210
- # Check for camel-cased methods
211
- @problem_count += 1 if line.method_line? and line.camel_case_method?
212
-
213
- # Check for non-camel-cased classes
214
- @problem_count += 1 if line.class_line? and line.snake_case_class?
215
-
216
- # Check for long lines
217
- @problem_count += 1 if line.too_long?
218
-
219
- # Check for spacing around operators
220
- =begin
221
- OPERATORS.each_pair do |op_group, op_values|
222
- op_values.each do |op|
223
- @problem_count += 1 if line.no_space_before? op
224
- @problem_count += 1 if line.no_space_after? op
225
- end
226
- end
227
- =end
228
-
229
- line_number += 1
230
- end
231
-
232
- @problem_count
233
- end
234
-
235
- # Prints a summary report that shows which files had how many problems.
236
- #
237
- # @param [Hash] files_and_problems Returns a hash that contains
238
- # file_name => problem_count.
239
- def self.print_report files_and_problems
240
- puts ""
241
- puts "The following files are out of style:"
242
-
243
- files_and_problems.each_pair do |file, problem_count|
244
- file_path = Pathname.new(file)
245
-
246
- unless problem_count == 0
247
- print "\t#{problem_count} problems in: "
248
- if files_and_problems.size > 1
249
- puts "#{file_path.relative_path_from(Pathname.pwd)}"
250
- else
251
- puts "#{file_path}"
252
- end
253
- end
254
- end
8
+ configuration
255
9
  end
256
10
  end