tailor 1.1.5 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +23 -23
- data/History.rdoc +14 -0
- data/README.rdoc +42 -2
- data/Rakefile +7 -0
- data/features/continuous_integration.feature +28 -0
- data/lib/tailor/cli.rb +17 -4
- data/lib/tailor/cli/options.rb +6 -0
- data/lib/tailor/configuration.rb +19 -3
- data/lib/tailor/configuration/style.rb +7 -0
- data/lib/tailor/critic.rb +4 -2
- data/lib/tailor/formatters/yaml.rb +51 -0
- data/lib/tailor/lexer.rb +6 -4
- data/lib/tailor/rake_task.rb +44 -6
- data/lib/tailor/reporter.rb +9 -3
- data/lib/tailor/rulers/allow_invalid_ruby_ruler.rb +3 -3
- data/lib/tailor/rulers/indentation_spaces_ruler.rb +24 -6
- data/lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb +2 -2
- data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +9 -6
- data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +1 -1
- data/lib/tailor/version.rb +1 -1
- data/spec/functional/configuration_spec.rb +37 -0
- data/spec/functional/horizontal_spacing/braces_spec.rb +113 -113
- data/spec/functional/horizontal_spacing/brackets_spec.rb +39 -39
- data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +27 -27
- data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +42 -42
- data/spec/functional/horizontal_spacing/long_lines_spec.rb +16 -16
- data/spec/functional/horizontal_spacing/parens_spec.rb +48 -48
- data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +23 -23
- data/spec/functional/horizontal_spacing_spec.rb +11 -11
- data/spec/functional/indentation_spacing/bad_indentation_spec.rb +212 -215
- data/spec/functional/indentation_spacing_spec.rb +8 -7
- data/spec/functional/naming/camel_case_methods_spec.rb +16 -16
- data/spec/functional/naming/screaming_snake_case_classes_spec.rb +30 -30
- data/spec/functional/naming_spec.rb +5 -4
- data/spec/functional/rake_task_spec.rb +56 -10
- data/spec/functional/vertical_spacing/class_length_spec.rb +16 -16
- data/spec/functional/vertical_spacing/method_length_spec.rb +16 -16
- data/spec/functional/vertical_spacing_spec.rb +5 -4
- data/spec/support/bad_indentation_cases.rb +35 -35
- data/spec/support/good_indentation_cases.rb +108 -108
- data/spec/support/horizontal_spacing_cases.rb +37 -37
- data/spec/support/naming_cases.rb +6 -6
- data/spec/support/vertical_spacing_cases.rb +4 -4
- data/spec/unit/tailor/cli_spec.rb +34 -12
- data/spec/unit/tailor/configuration_spec.rb +18 -0
- data/spec/unit/tailor/formatters/yaml_spec.rb +75 -0
- data/spec/unit/tailor/reporter_spec.rb +23 -4
- data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +12 -10
- data/spec/unit/tailor/version_spec.rb +3 -2
- metadata +35 -63
@@ -4,14 +4,14 @@ require 'tailor/configuration/style'
|
|
4
4
|
|
5
5
|
|
6
6
|
BRACKETS = {}
|
7
|
-
BRACKETS[
|
8
|
-
BRACKETS[
|
9
|
-
BRACKETS[
|
10
|
-
BRACKETS[
|
11
|
-
BRACKETS[
|
12
|
-
BRACKETS[
|
7
|
+
BRACKETS['space_in_empty_array'] = %Q{[ ]}
|
8
|
+
BRACKETS['simple_array_space_after_lbracket'] = %Q{[ 1, 2, 3]}
|
9
|
+
BRACKETS['simple_array_space_before_rbracket'] = %Q{[1, 2, 3 ]}
|
10
|
+
BRACKETS['hash_key_ref_space_before_rbracket'] = %Q{thing[:one ]}
|
11
|
+
BRACKETS['hash_key_ref_space_after_lbracket'] = %Q{thing[ :one]}
|
12
|
+
BRACKETS['two_d_array_space_after_lbrackets'] =
|
13
13
|
%Q{[ [1, 2, 3], [ 'a', 'b', 'c']]}
|
14
|
-
BRACKETS[
|
14
|
+
BRACKETS['two_d_array_space_before_rbrackets'] =
|
15
15
|
%Q{[[1, 2, 3 ], [ 'a', 'b', 'c'] ]}
|
16
16
|
|
17
17
|
|
@@ -19,8 +19,8 @@ describe "Detection of spaces around brackets" do
|
|
19
19
|
before do
|
20
20
|
Tailor::Logger.stub(:log)
|
21
21
|
FakeFS.activate!
|
22
|
-
File.open(file_name
|
23
|
-
critic.check_file(file_name
|
22
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
23
|
+
critic.check_file(file_name, style.to_hash)
|
24
24
|
end
|
25
25
|
|
26
26
|
let(:critic) do
|
@@ -39,50 +39,50 @@ describe "Detection of spaces around brackets" do
|
|
39
39
|
|
40
40
|
context "Arrays" do
|
41
41
|
context "empty with space inside" do
|
42
|
-
let(:file_name) {
|
43
|
-
specify { critic.problems[file_name
|
44
|
-
specify { critic.problems[file_name
|
45
|
-
specify { critic.problems[file_name
|
46
|
-
specify { critic.problems[file_name
|
47
|
-
specify { critic.problems[file_name
|
42
|
+
let(:file_name) { 'space_in_empty_array' }
|
43
|
+
specify { critic.problems[file_name].size.should be 1 }
|
44
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_lbracket" }
|
45
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
46
|
+
specify { critic.problems[file_name].first[:column].should be 1 }
|
47
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
48
48
|
end
|
49
49
|
|
50
50
|
context "space after lbracket" do
|
51
|
-
let(:file_name) {
|
52
|
-
specify { critic.problems[file_name
|
53
|
-
specify { critic.problems[file_name
|
54
|
-
specify { critic.problems[file_name
|
55
|
-
specify { critic.problems[file_name
|
56
|
-
specify { critic.problems[file_name
|
51
|
+
let(:file_name) { 'simple_array_space_after_lbracket' }
|
52
|
+
specify { critic.problems[file_name].size.should be 1 }
|
53
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_lbracket" }
|
54
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
55
|
+
specify { critic.problems[file_name].first[:column].should be 1 }
|
56
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
57
57
|
end
|
58
58
|
|
59
59
|
context "space before rbracket" do
|
60
|
-
let(:file_name) {
|
61
|
-
specify { critic.problems[file_name
|
62
|
-
specify { critic.problems[file_name
|
63
|
-
specify { critic.problems[file_name
|
64
|
-
specify { critic.problems[file_name
|
65
|
-
specify { critic.problems[file_name
|
60
|
+
let(:file_name) { 'simple_array_space_before_rbracket' }
|
61
|
+
specify { critic.problems[file_name].size.should be 1 }
|
62
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_before_rbracket" }
|
63
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
64
|
+
specify { critic.problems[file_name].first[:column].should be 9 }
|
65
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
context "Hash key references" do
|
70
70
|
context "space before rbracket" do
|
71
|
-
let(:file_name) {
|
72
|
-
specify { critic.problems[file_name
|
73
|
-
specify { critic.problems[file_name
|
74
|
-
specify { critic.problems[file_name
|
75
|
-
specify { critic.problems[file_name
|
76
|
-
specify { critic.problems[file_name
|
71
|
+
let(:file_name) { 'hash_key_ref_space_before_rbracket' }
|
72
|
+
specify { critic.problems[file_name].size.should be 1 }
|
73
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_before_rbracket" }
|
74
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
75
|
+
specify { critic.problems[file_name].first[:column].should be 11 }
|
76
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
77
77
|
end
|
78
78
|
|
79
79
|
context "space after lbracket" do
|
80
|
-
let(:file_name) {
|
81
|
-
specify { critic.problems[file_name
|
82
|
-
specify { critic.problems[file_name
|
83
|
-
specify { critic.problems[file_name
|
84
|
-
specify { critic.problems[file_name
|
85
|
-
specify { critic.problems[file_name
|
80
|
+
let(:file_name) { 'hash_key_ref_space_after_lbracket' }
|
81
|
+
specify { critic.problems[file_name].size.should be 1 }
|
82
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_lbracket" }
|
83
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
84
|
+
specify { critic.problems[file_name].first[:column].should be 6 }
|
85
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -4,14 +4,14 @@ require 'tailor/configuration/style'
|
|
4
4
|
|
5
5
|
|
6
6
|
COMMA_SPACING = {}
|
7
|
-
COMMA_SPACING[
|
8
|
-
COMMA_SPACING[
|
9
|
-
COMMA_SPACING[
|
10
|
-
COMMA_SPACING[
|
11
|
-
COMMA_SPACING[
|
12
|
-
COMMA_SPACING[
|
7
|
+
COMMA_SPACING['no_space_after_comma'] = %Q{[1,2]}
|
8
|
+
COMMA_SPACING['two_spaces_after_comma'] = %Q{[1, 2]}
|
9
|
+
COMMA_SPACING['one_space_before_comma'] = %Q{[1 , 2]}
|
10
|
+
COMMA_SPACING['two_spaces_before_comma'] = %Q{[1 , 2]}
|
11
|
+
COMMA_SPACING['two_spaces_before_comma_twice'] = %Q{[1 , 2 , 3]}
|
12
|
+
COMMA_SPACING['two_spaces_after_comma_twice'] = %Q{[1, 2, 3]}
|
13
13
|
|
14
|
-
COMMA_SPACING[
|
14
|
+
COMMA_SPACING['spaces_before_with_trailing_comments'] = %Q{[
|
15
15
|
1 , # Comment!
|
16
16
|
2 , # Another comment.
|
17
17
|
}
|
@@ -21,8 +21,8 @@ describe "Spacing around comma detection" do
|
|
21
21
|
before do
|
22
22
|
Tailor::Logger.stub(:log)
|
23
23
|
FakeFS.activate!
|
24
|
-
File.open(file_name
|
25
|
-
critic.check_file(file_name
|
24
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
25
|
+
critic.check_file(file_name, style.to_hash)
|
26
26
|
end
|
27
27
|
|
28
28
|
let(:critic) do
|
@@ -40,29 +40,29 @@ describe "Spacing around comma detection" do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
context "no space after a comma" do
|
43
|
-
let(:file_name) {
|
44
|
-
specify { critic.problems[file_name
|
45
|
-
specify { critic.problems[file_name
|
46
|
-
specify { critic.problems[file_name
|
47
|
-
specify { critic.problems[file_name
|
48
|
-
specify { critic.problems[file_name
|
43
|
+
let(:file_name) { 'no_space_after_comma' }
|
44
|
+
specify { critic.problems[file_name].size.should be 1 }
|
45
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_comma" }
|
46
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
47
|
+
specify { critic.problems[file_name].first[:column].should be 3 }
|
48
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
49
49
|
end
|
50
50
|
|
51
51
|
context "two spaces after a comma" do
|
52
|
-
let(:file_name) {
|
53
|
-
specify { critic.problems[file_name
|
54
|
-
specify { critic.problems[file_name
|
55
|
-
specify { critic.problems[file_name
|
56
|
-
specify { critic.problems[file_name
|
57
|
-
specify { critic.problems[file_name
|
52
|
+
let(:file_name) { 'two_spaces_after_comma' }
|
53
|
+
specify { critic.problems[file_name].size.should be 1 }
|
54
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_comma" }
|
55
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
56
|
+
specify { critic.problems[file_name].first[:column].should be 3 }
|
57
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
58
58
|
end
|
59
59
|
|
60
60
|
context "one space before comma" do
|
61
|
-
let(:file_name) {
|
62
|
-
specify { critic.problems[file_name
|
63
|
-
specify { critic.problems[file_name
|
64
|
-
specify { critic.problems[file_name
|
65
|
-
specify { critic.problems[file_name
|
66
|
-
specify { critic.problems[file_name
|
61
|
+
let(:file_name) { 'one_space_before_comma' }
|
62
|
+
specify { critic.problems[file_name].size.should be 1 }
|
63
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_before_comma" }
|
64
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
65
|
+
specify { critic.problems[file_name].first[:column].should be 2 }
|
66
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
67
67
|
end
|
68
68
|
end
|
@@ -7,12 +7,12 @@ require 'tailor/configuration/style'
|
|
7
7
|
#-------------------------------------------------------------------------------
|
8
8
|
HARD_TABS = {}
|
9
9
|
|
10
|
-
HARD_TABS[
|
10
|
+
HARD_TABS['hard_tab'] =
|
11
11
|
%Q{def something
|
12
12
|
\tputs "something"
|
13
13
|
end}
|
14
14
|
|
15
|
-
HARD_TABS[
|
15
|
+
HARD_TABS['hard_tab_with_spaces'] =
|
16
16
|
%Q{class Thing
|
17
17
|
def something
|
18
18
|
\t puts "something"
|
@@ -24,14 +24,14 @@ end}
|
|
24
24
|
# looks correct to the parser. I'm leaving this behavior, as detecting the
|
25
25
|
# hard tab should signal the problem. If you fix the hard tab and don't
|
26
26
|
# fix indentation, tailor will flag you on the indentation on the next run.
|
27
|
-
HARD_TABS[
|
27
|
+
HARD_TABS['hard_tab_with_1_indented_space'] =
|
28
28
|
%Q{class Thing
|
29
29
|
def something
|
30
30
|
\t puts "something"
|
31
31
|
end
|
32
32
|
end}
|
33
33
|
|
34
|
-
HARD_TABS[
|
34
|
+
HARD_TABS['hard_tab_with_2_indented_spaces'] =
|
35
35
|
%Q{class Thing
|
36
36
|
def something
|
37
37
|
\t puts "something"
|
@@ -42,8 +42,8 @@ describe "Hard tab detection" do
|
|
42
42
|
before do
|
43
43
|
Tailor::Logger.stub(:log)
|
44
44
|
FakeFS.activate!
|
45
|
-
File.open(file_name
|
46
|
-
critic.check_file(file_name
|
45
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
46
|
+
critic.check_file(file_name, style.to_hash)
|
47
47
|
end
|
48
48
|
|
49
49
|
let(:critic) do
|
@@ -61,50 +61,50 @@ describe "Hard tab detection" do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
context "1 hard tab" do
|
64
|
-
let(:file_name) {
|
65
|
-
specify { critic.problems[file_name
|
66
|
-
specify { critic.problems[file_name
|
67
|
-
specify { critic.problems[file_name
|
68
|
-
specify { critic.problems[file_name
|
69
|
-
specify { critic.problems[file_name
|
70
|
-
specify { critic.problems[file_name
|
71
|
-
specify { critic.problems[file_name
|
72
|
-
specify { critic.problems[file_name
|
73
|
-
specify { critic.problems[file_name
|
64
|
+
let(:file_name) { 'hard_tab' }
|
65
|
+
specify { critic.problems[file_name].size.should be 2 }
|
66
|
+
specify { critic.problems[file_name].first[:type].should == "allow_hard_tabs" }
|
67
|
+
specify { critic.problems[file_name].first[:line].should be 2 }
|
68
|
+
specify { critic.problems[file_name].first[:column].should be 0 }
|
69
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
70
|
+
specify { critic.problems[file_name].last[:type].should == "indentation_spaces" }
|
71
|
+
specify { critic.problems[file_name].last[:line].should be 2 }
|
72
|
+
specify { critic.problems[file_name].last[:column].should be 1 }
|
73
|
+
specify { critic.problems[file_name].last[:level].should be :error }
|
74
74
|
end
|
75
75
|
|
76
76
|
context "1 hard tab with 2 spaces after it" do
|
77
|
-
let(:file_name) {
|
78
|
-
specify { critic.problems[file_name
|
79
|
-
specify { critic.problems[file_name
|
80
|
-
specify { critic.problems[file_name
|
81
|
-
specify { critic.problems[file_name
|
82
|
-
specify { critic.problems[file_name
|
83
|
-
specify { critic.problems[file_name
|
84
|
-
specify { critic.problems[file_name
|
85
|
-
specify { critic.problems[file_name
|
86
|
-
specify { critic.problems[file_name
|
77
|
+
let(:file_name) { 'hard_tab_with_spaces' }
|
78
|
+
specify { critic.problems[file_name].size.should be 2 }
|
79
|
+
specify { critic.problems[file_name].first[:type].should == "allow_hard_tabs" }
|
80
|
+
specify { critic.problems[file_name].first[:line].should be 3 }
|
81
|
+
specify { critic.problems[file_name].first[:column].should be 0 }
|
82
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
83
|
+
specify { critic.problems[file_name].last[:type].should == "indentation_spaces" }
|
84
|
+
specify { critic.problems[file_name].last[:line].should be 3 }
|
85
|
+
specify { critic.problems[file_name].last[:column].should be 3 }
|
86
|
+
specify { critic.problems[file_name].last[:level].should be :error }
|
87
87
|
end
|
88
88
|
|
89
89
|
context "1 hard tab with 3 spaces after it" do
|
90
|
-
let(:file_name) {
|
91
|
-
specify { critic.problems[file_name
|
92
|
-
specify { critic.problems[file_name
|
93
|
-
specify { critic.problems[file_name
|
94
|
-
specify { critic.problems[file_name
|
95
|
-
specify { critic.problems[file_name
|
90
|
+
let(:file_name) { 'hard_tab_with_1_indented_space' }
|
91
|
+
specify { critic.problems[file_name].size.should be 1 }
|
92
|
+
specify { critic.problems[file_name].first[:type].should == "allow_hard_tabs" }
|
93
|
+
specify { critic.problems[file_name].first[:line].should be 3 }
|
94
|
+
specify { critic.problems[file_name].first[:column].should be 0 }
|
95
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
96
96
|
end
|
97
97
|
|
98
98
|
context "1 hard tab with 4 spaces after it" do
|
99
|
-
let(:file_name) {
|
100
|
-
specify { critic.problems[file_name
|
101
|
-
specify { critic.problems[file_name
|
102
|
-
specify { critic.problems[file_name
|
103
|
-
specify { critic.problems[file_name
|
104
|
-
specify { critic.problems[file_name
|
105
|
-
specify { critic.problems[file_name
|
106
|
-
specify { critic.problems[file_name
|
107
|
-
specify { critic.problems[file_name
|
108
|
-
specify { critic.problems[file_name
|
99
|
+
let(:file_name) { 'hard_tab_with_2_indented_spaces' }
|
100
|
+
specify { critic.problems[file_name].size.should be 2 }
|
101
|
+
specify { critic.problems[file_name].first[:type].should == "allow_hard_tabs" }
|
102
|
+
specify { critic.problems[file_name].first[:line].should be 3 }
|
103
|
+
specify { critic.problems[file_name].first[:column].should be 0 }
|
104
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
105
|
+
specify { critic.problems[file_name].last[:type].should == "indentation_spaces" }
|
106
|
+
specify { critic.problems[file_name].last[:line].should be 3 }
|
107
|
+
specify { critic.problems[file_name].last[:column].should be 5 }
|
108
|
+
specify { critic.problems[file_name].last[:level].should be :error }
|
109
109
|
end
|
110
110
|
end
|
@@ -4,8 +4,8 @@ require 'tailor/configuration/style'
|
|
4
4
|
|
5
5
|
|
6
6
|
LONG_LINE = {}
|
7
|
-
LONG_LINE[
|
8
|
-
LONG_LINE[
|
7
|
+
LONG_LINE['long_line_no_newline'] = %Q{'#{'#' * 79}'}
|
8
|
+
LONG_LINE['long_line_newline_at_82'] = %Q{'#{'#' * 79}'
|
9
9
|
}
|
10
10
|
|
11
11
|
|
@@ -13,8 +13,8 @@ describe "Long line detection" do
|
|
13
13
|
before do
|
14
14
|
Tailor::Logger.stub(:log)
|
15
15
|
FakeFS.activate!
|
16
|
-
File.open(file_name
|
17
|
-
critic.check_file(file_name
|
16
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
17
|
+
critic.check_file(file_name, style.to_hash)
|
18
18
|
end
|
19
19
|
|
20
20
|
let(:critic) do
|
@@ -32,20 +32,20 @@ describe "Long line detection" do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
context "line is 81 chars, no newline" do
|
35
|
-
let(:file_name) {
|
36
|
-
specify { critic.problems[file_name
|
37
|
-
specify { critic.problems[file_name
|
38
|
-
specify { critic.problems[file_name
|
39
|
-
specify { critic.problems[file_name
|
40
|
-
specify { critic.problems[file_name
|
35
|
+
let(:file_name) { 'long_line_no_newline' }
|
36
|
+
specify { critic.problems[file_name].size.should be 1 }
|
37
|
+
specify { critic.problems[file_name].first[:type].should == "max_line_length" }
|
38
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
39
|
+
specify { critic.problems[file_name].first[:column].should be 81 }
|
40
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
41
41
|
end
|
42
42
|
|
43
43
|
context "line is 81 chars, plus a newline" do
|
44
|
-
let(:file_name) {
|
45
|
-
specify { critic.problems[file_name
|
46
|
-
specify { critic.problems[file_name
|
47
|
-
specify { critic.problems[file_name
|
48
|
-
specify { critic.problems[file_name
|
49
|
-
specify { critic.problems[file_name
|
44
|
+
let(:file_name) { 'long_line_newline_at_82' }
|
45
|
+
specify { critic.problems[file_name].size.should be 1 }
|
46
|
+
specify { critic.problems[file_name].first[:type].should == "max_line_length" }
|
47
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
48
|
+
specify { critic.problems[file_name].first[:column].should be 81 }
|
49
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
50
50
|
end
|
51
51
|
end
|
@@ -4,16 +4,16 @@ require 'tailor/configuration/style'
|
|
4
4
|
|
5
5
|
|
6
6
|
PARENS = {}
|
7
|
-
PARENS[
|
8
|
-
PARENS[
|
9
|
-
PARENS[
|
7
|
+
PARENS['simple_method_call_space_after_lparen'] = %Q{thing( one, two)}
|
8
|
+
PARENS['simple_method_call_space_before_rparen'] = %Q{thing(one, two )}
|
9
|
+
PARENS['method_call_space_after_lparen_trailing_comment'] =
|
10
10
|
%Q{thing( one, two) # comment}
|
11
|
-
PARENS[
|
11
|
+
PARENS['method_call_space_after_lparen_before_rparen_trailing_comment'] =
|
12
12
|
%Q{thing( one, two ) # comment}
|
13
13
|
|
14
|
-
PARENS[
|
14
|
+
PARENS['multi_line_method_call_space_after_lparen'] = %Q{thing( one,
|
15
15
|
two)}
|
16
|
-
PARENS[
|
16
|
+
PARENS['multi_line_method_call_space_after_lparen_trailing_comment'] =
|
17
17
|
%Q{thing( one,
|
18
18
|
two)}
|
19
19
|
|
@@ -21,8 +21,8 @@ describe "Detection of spaces around brackets" do
|
|
21
21
|
before do
|
22
22
|
Tailor::Logger.stub(:log)
|
23
23
|
FakeFS.activate!
|
24
|
-
File.open(file_name
|
25
|
-
critic.check_file(file_name
|
24
|
+
File.open(file_name, 'w') { |f| f.write contents }
|
25
|
+
critic.check_file(file_name, style.to_hash)
|
26
26
|
end
|
27
27
|
|
28
28
|
let(:critic) do
|
@@ -41,62 +41,62 @@ describe "Detection of spaces around brackets" do
|
|
41
41
|
|
42
42
|
context "methods" do
|
43
43
|
context "space after lparen" do
|
44
|
-
let(:file_name) {
|
45
|
-
specify { critic.problems[file_name
|
46
|
-
specify { critic.problems[file_name
|
47
|
-
specify { critic.problems[file_name
|
48
|
-
specify { critic.problems[file_name
|
49
|
-
specify { critic.problems[file_name
|
44
|
+
let(:file_name) { 'simple_method_call_space_after_lparen' }
|
45
|
+
specify { critic.problems[file_name].size.should be 1 }
|
46
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_lparen" }
|
47
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
48
|
+
specify { critic.problems[file_name].first[:column].should be 6 }
|
49
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
50
50
|
end
|
51
51
|
|
52
52
|
context "space before rparen" do
|
53
|
-
let(:file_name) {
|
54
|
-
specify { critic.problems[file_name
|
55
|
-
specify { critic.problems[file_name
|
56
|
-
specify { critic.problems[file_name
|
57
|
-
specify { critic.problems[file_name
|
58
|
-
specify { critic.problems[file_name
|
53
|
+
let(:file_name) { 'simple_method_call_space_before_rparen' }
|
54
|
+
specify { critic.problems[file_name].size.should be 1 }
|
55
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_before_rparen" }
|
56
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
57
|
+
specify { critic.problems[file_name].first[:column].should be 15 }
|
58
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
59
59
|
end
|
60
60
|
|
61
61
|
context "space after lparen, trailing comment" do
|
62
|
-
let(:file_name) {
|
63
|
-
specify { critic.problems[file_name
|
64
|
-
specify { critic.problems[file_name
|
65
|
-
specify { critic.problems[file_name
|
66
|
-
specify { critic.problems[file_name
|
67
|
-
specify { critic.problems[file_name
|
62
|
+
let(:file_name) { 'method_call_space_after_lparen_trailing_comment' }
|
63
|
+
specify { critic.problems[file_name].size.should be 1 }
|
64
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_lparen" }
|
65
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
66
|
+
specify { critic.problems[file_name].first[:column].should be 6 }
|
67
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
68
68
|
end
|
69
69
|
|
70
70
|
context "space after lparen, before rparen, trailing comment" do
|
71
|
-
let(:file_name) {
|
72
|
-
specify { critic.problems[file_name
|
73
|
-
specify { critic.problems[file_name
|
74
|
-
specify { critic.problems[file_name
|
75
|
-
specify { critic.problems[file_name
|
76
|
-
specify { critic.problems[file_name
|
77
|
-
specify { critic.problems[file_name
|
78
|
-
specify { critic.problems[file_name
|
79
|
-
specify { critic.problems[file_name
|
80
|
-
specify { critic.problems[file_name
|
71
|
+
let(:file_name) { 'method_call_space_after_lparen_before_rparen_trailing_comment' }
|
72
|
+
specify { critic.problems[file_name].size.should be 2 }
|
73
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_lparen" }
|
74
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
75
|
+
specify { critic.problems[file_name].first[:column].should be 6 }
|
76
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
77
|
+
specify { critic.problems[file_name].last[:type].should == "spaces_before_rparen" }
|
78
|
+
specify { critic.problems[file_name].last[:line].should be 1 }
|
79
|
+
specify { critic.problems[file_name].last[:column].should be 16 }
|
80
|
+
specify { critic.problems[file_name].last[:level].should be :error }
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
context "multi-line method calls" do
|
85
85
|
context "space after lparen" do
|
86
|
-
let(:file_name) {
|
87
|
-
specify { critic.problems[file_name
|
88
|
-
specify { critic.problems[file_name
|
89
|
-
specify { critic.problems[file_name
|
90
|
-
specify { critic.problems[file_name
|
91
|
-
specify { critic.problems[file_name
|
86
|
+
let(:file_name) { 'multi_line_method_call_space_after_lparen' }
|
87
|
+
specify { critic.problems[file_name].size.should be 1 }
|
88
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_lparen" }
|
89
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
90
|
+
specify { critic.problems[file_name].first[:column].should be 6 }
|
91
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
92
92
|
end
|
93
93
|
context "space after lparen, trailing comment" do
|
94
|
-
let(:file_name) {
|
95
|
-
specify { critic.problems[file_name
|
96
|
-
specify { critic.problems[file_name
|
97
|
-
specify { critic.problems[file_name
|
98
|
-
specify { critic.problems[file_name
|
99
|
-
specify { critic.problems[file_name
|
94
|
+
let(:file_name) { 'multi_line_method_call_space_after_lparen_trailing_comment' }
|
95
|
+
specify { critic.problems[file_name].size.should be 1 }
|
96
|
+
specify { critic.problems[file_name].first[:type].should == "spaces_after_lparen" }
|
97
|
+
specify { critic.problems[file_name].first[:line].should be 1 }
|
98
|
+
specify { critic.problems[file_name].first[:column].should be 6 }
|
99
|
+
specify { critic.problems[file_name].first[:level].should be :error }
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|