tailor 1.0.1 → 1.1.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.
- data/.tailor +1 -0
- data/Gemfile.lock +1 -1
- data/History.rdoc +34 -0
- data/README.rdoc +17 -1
- data/features/valid_ruby.feature +1 -1
- data/lib/ext/string_ext.rb +0 -4
- data/lib/tailor/cli/options.rb +9 -2
- data/lib/tailor/configuration.rb +103 -150
- data/lib/tailor/configuration/file_set.rb +110 -0
- data/lib/tailor/formatters/text.rb +108 -79
- data/lib/tailor/rake_task.rb +148 -0
- data/lib/tailor/tailorrc.erb +1 -1
- data/lib/tailor/version.rb +1 -1
- data/spec/functional/configuration_spec.rb +244 -0
- data/spec/functional/horizontal_spacing/braces_spec.rb +238 -0
- data/spec/functional/horizontal_spacing/brackets_spec.rb +88 -0
- data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +68 -0
- data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +110 -0
- data/spec/functional/horizontal_spacing/long_lines_spec.rb +51 -0
- data/spec/functional/horizontal_spacing/parens_spec.rb +102 -0
- data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +66 -0
- data/spec/functional/horizontal_spacing_spec.rb +59 -0
- data/spec/functional/indentation_spacing/bad_indentation_spec.rb +372 -0
- data/spec/functional/indentation_spacing_spec.rb +85 -0
- data/spec/functional/naming/camel_case_methods_spec.rb +56 -0
- data/spec/functional/naming/screaming_snake_case_classes_spec.rb +83 -0
- data/spec/functional/naming_spec.rb +35 -0
- data/spec/functional/vertical_spacing/class_length_spec.rb +67 -0
- data/spec/functional/vertical_spacing/method_length_spec.rb +61 -0
- data/spec/functional/vertical_spacing_spec.rb +35 -0
- data/spec/support/bad_indentation_cases.rb +265 -0
- data/{features/support/file_cases/indentation_cases.rb → spec/support/good_indentation_cases.rb} +6 -266
- data/spec/support/horizontal_spacing_cases.rb +136 -0
- data/spec/support/naming_cases.rb +26 -0
- data/{features/support/file_cases → spec/support}/vertical_spacing_cases.rb +0 -33
- data/spec/{tailor → unit/tailor}/cli_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/composite_observable_spec.rb +1 -1
- data/spec/unit/tailor/configuration/file_set_spec.rb +65 -0
- data/spec/{tailor → unit/tailor}/configuration/style_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/configuration_spec.rb +1 -59
- data/spec/{tailor → unit/tailor}/critic_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/formatter_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/lexed_line_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/lexer/token_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/lexer_spec.rb +1 -2
- data/spec/{tailor → unit/tailor}/options_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/problem_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/reporter_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/ruler_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/rulers/indentation_spaces_ruler_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/rulers/spaces_after_comma_ruler_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/rulers/spaces_after_lbrace_ruler_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/rulers/spaces_before_lbrace_ruler_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/rulers/spaces_before_rbrace_ruler_spec.rb +1 -1
- data/spec/{tailor → unit/tailor}/rulers_spec.rb +1 -1
- data/spec/unit/tailor/version_spec.rb +6 -0
- data/spec/{tailor_spec.rb → unit/tailor_spec.rb} +1 -1
- data/tasks/spec.rake +8 -3
- metadata +121 -93
- data/features/horizontal_spacing.feature +0 -263
- data/features/indentation/bad_files_with_no_trailing_newline.feature +0 -91
- data/features/indentation/good_files_with_no_trailing_newline.feature +0 -219
- data/features/name_detection.feature +0 -72
- data/features/support/file_cases/horizontal_spacing_cases.rb +0 -266
- data/features/support/file_cases/naming_cases.rb +0 -51
- data/features/vertical_spacing.feature +0 -135
- data/m.rb +0 -15
- data/spec/tailor/version_spec.rb +0 -6
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'tailor/critic'
|
3
|
+
require 'tailor/configuration/style'
|
4
|
+
|
5
|
+
|
6
|
+
CAMEL_CASE_METHODS = {}
|
7
|
+
|
8
|
+
CAMEL_CASE_METHODS[:one_caps_camel_case_method] =
|
9
|
+
%Q{def thingOne
|
10
|
+
end}
|
11
|
+
|
12
|
+
CAMEL_CASE_METHODS[:one_caps_camel_case_method_trailing_comment] =
|
13
|
+
%Q{def thingOne # comment
|
14
|
+
end}
|
15
|
+
|
16
|
+
|
17
|
+
describe "Detection of camel case methods" do
|
18
|
+
before do
|
19
|
+
Tailor::Logger.stub(:log)
|
20
|
+
FakeFS.activate!
|
21
|
+
File.open(file_name.to_s, 'w') { |f| f.write contents }
|
22
|
+
critic.check_file(file_name.to_s, style.to_hash)
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:critic) do
|
26
|
+
Tailor::Critic.new
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:contents) { CAMEL_CASE_METHODS[file_name] }
|
30
|
+
|
31
|
+
let(:style) do
|
32
|
+
style = Tailor::Configuration::Style.new
|
33
|
+
style.trailing_newlines 0, level: :off
|
34
|
+
style.allow_invalid_ruby true, level: :off
|
35
|
+
|
36
|
+
style
|
37
|
+
end
|
38
|
+
|
39
|
+
context "standard camel case method" do
|
40
|
+
let(:file_name) { :one_caps_camel_case_method }
|
41
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
42
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "allow_camel_case_methods" }
|
43
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
44
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 4 }
|
45
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
46
|
+
end
|
47
|
+
|
48
|
+
context "standard camel case method, trailing comment" do
|
49
|
+
let(:file_name) { :one_caps_camel_case_method_trailing_comment }
|
50
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
51
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "allow_camel_case_methods" }
|
52
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
53
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 4 }
|
54
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'tailor/critic'
|
3
|
+
require 'tailor/configuration/style'
|
4
|
+
|
5
|
+
|
6
|
+
SCREAMING_SNAKE_CASE_CLASSES = {}
|
7
|
+
|
8
|
+
SCREAMING_SNAKE_CASE_CLASSES[:one_screaming_snake_case_class] =
|
9
|
+
%Q{class Thing_One
|
10
|
+
end}
|
11
|
+
|
12
|
+
SCREAMING_SNAKE_CASE_CLASSES[:one_screaming_snake_case_module] =
|
13
|
+
%Q{module Thing_One
|
14
|
+
end}
|
15
|
+
|
16
|
+
SCREAMING_SNAKE_CASE_CLASSES[:double_screaming_snake_case_class] =
|
17
|
+
%Q{class Thing_One_Again
|
18
|
+
end}
|
19
|
+
|
20
|
+
SCREAMING_SNAKE_CASE_CLASSES[:double_screaming_snake_case_module] =
|
21
|
+
%Q{module Thing_One_Again
|
22
|
+
end}
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
describe "Detection of camel case methods" do
|
27
|
+
before do
|
28
|
+
Tailor::Logger.stub(:log)
|
29
|
+
FakeFS.activate!
|
30
|
+
File.open(file_name.to_s, 'w') { |f| f.write contents }
|
31
|
+
critic.check_file(file_name.to_s, style.to_hash)
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:critic) do
|
35
|
+
Tailor::Critic.new
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:contents) { SCREAMING_SNAKE_CASE_CLASSES[file_name] }
|
39
|
+
|
40
|
+
let(:style) do
|
41
|
+
style = Tailor::Configuration::Style.new
|
42
|
+
style.trailing_newlines 0, level: :off
|
43
|
+
style.allow_invalid_ruby true, level: :off
|
44
|
+
|
45
|
+
style
|
46
|
+
end
|
47
|
+
|
48
|
+
context "standard screaming snake case class" do
|
49
|
+
let(:file_name) { :one_screaming_snake_case_class }
|
50
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
51
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "allow_screaming_snake_case_classes" }
|
52
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
53
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 6 }
|
54
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
55
|
+
end
|
56
|
+
|
57
|
+
context "standard screaming snake case module" do
|
58
|
+
let(:file_name) { :one_screaming_snake_case_module }
|
59
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
60
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "allow_screaming_snake_case_classes" }
|
61
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
62
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 7 }
|
63
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "double screaming snake case class" do
|
67
|
+
let(:file_name) { :double_screaming_snake_case_class }
|
68
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
69
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "allow_screaming_snake_case_classes" }
|
70
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
71
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 6 }
|
72
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
73
|
+
end
|
74
|
+
|
75
|
+
context "double screaming snake case module" do
|
76
|
+
let(:file_name) { :double_screaming_snake_case_module }
|
77
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
78
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "allow_screaming_snake_case_classes" }
|
79
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
80
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 7 }
|
81
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../support/naming_cases'
|
3
|
+
require 'tailor/critic'
|
4
|
+
require 'tailor/configuration/style'
|
5
|
+
|
6
|
+
describe "Naming problem detection" do
|
7
|
+
before do
|
8
|
+
Tailor::Logger.stub(:log)
|
9
|
+
FakeFS.activate!
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:critic) do
|
13
|
+
Tailor::Critic.new
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:style) do
|
17
|
+
style = Tailor::Configuration::Style.new
|
18
|
+
style.trailing_newlines 0, level: :off
|
19
|
+
style.allow_invalid_ruby true, level: :off
|
20
|
+
|
21
|
+
style
|
22
|
+
end
|
23
|
+
|
24
|
+
NAMING_OK.each do |file_name, contents|
|
25
|
+
before do
|
26
|
+
FileUtils.touch file_name.to_s
|
27
|
+
File.open(file_name.to_s, 'w') { |f| f.write contents }
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be OK" do
|
31
|
+
critic.check_file(file_name.to_s, style.to_hash)
|
32
|
+
critic.problems.should == { file_name.to_s => [] }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'tailor/critic'
|
3
|
+
require 'tailor/configuration/style'
|
4
|
+
|
5
|
+
|
6
|
+
CLASS_LENGTH = {}
|
7
|
+
CLASS_LENGTH[:class_too_long] =
|
8
|
+
%Q{class Party
|
9
|
+
include Clowns
|
10
|
+
include Pizza
|
11
|
+
|
12
|
+
def barrel_roll
|
13
|
+
puts "DOABARRELROLL!"
|
14
|
+
end
|
15
|
+
end}
|
16
|
+
|
17
|
+
CLASS_LENGTH[:parent_class_too_long] =
|
18
|
+
%Q{class Party
|
19
|
+
|
20
|
+
class Pizza
|
21
|
+
include Cheese
|
22
|
+
include Yumminess
|
23
|
+
end
|
24
|
+
end}
|
25
|
+
|
26
|
+
|
27
|
+
describe "Detection of class length" do
|
28
|
+
before do
|
29
|
+
Tailor::Logger.stub(:log)
|
30
|
+
FakeFS.activate!
|
31
|
+
File.open(file_name.to_s, 'w') { |f| f.write contents }
|
32
|
+
critic.check_file(file_name.to_s, style.to_hash)
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:critic) do
|
36
|
+
Tailor::Critic.new
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:contents) { CLASS_LENGTH[file_name] }
|
40
|
+
|
41
|
+
let(:style) do
|
42
|
+
style = Tailor::Configuration::Style.new
|
43
|
+
style.trailing_newlines 0, level: :off
|
44
|
+
style.allow_invalid_ruby true, level: :off
|
45
|
+
style.max_code_lines_in_class 5
|
46
|
+
|
47
|
+
style
|
48
|
+
end
|
49
|
+
|
50
|
+
context "single class" do
|
51
|
+
let(:file_name) { :class_too_long }
|
52
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
53
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "max_code_lines_in_class" }
|
54
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
55
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 0 }
|
56
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
57
|
+
end
|
58
|
+
|
59
|
+
context "class in a class" do
|
60
|
+
let(:file_name) { :parent_class_too_long }
|
61
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
62
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "max_code_lines_in_class" }
|
63
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
64
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 0 }
|
65
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
require 'tailor/critic'
|
3
|
+
require 'tailor/configuration/style'
|
4
|
+
|
5
|
+
|
6
|
+
METHOD_LENGTH = {}
|
7
|
+
METHOD_LENGTH[:method_too_long] =
|
8
|
+
%Q{def thing
|
9
|
+
puts
|
10
|
+
puts
|
11
|
+
end}
|
12
|
+
|
13
|
+
METHOD_LENGTH[:parent_method_too_long] =
|
14
|
+
%Q{def thing
|
15
|
+
puts
|
16
|
+
def inner_thing; print '1'; end
|
17
|
+
puts
|
18
|
+
end}
|
19
|
+
|
20
|
+
|
21
|
+
describe "Detection of method length" do
|
22
|
+
before do
|
23
|
+
Tailor::Logger.stub(:log)
|
24
|
+
FakeFS.activate!
|
25
|
+
File.open(file_name.to_s, 'w') { |f| f.write contents }
|
26
|
+
critic.check_file(file_name.to_s, style.to_hash)
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:critic) do
|
30
|
+
Tailor::Critic.new
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:contents) { METHOD_LENGTH[file_name] }
|
34
|
+
|
35
|
+
let(:style) do
|
36
|
+
style = Tailor::Configuration::Style.new
|
37
|
+
style.trailing_newlines 0, level: :off
|
38
|
+
style.allow_invalid_ruby true, level: :off
|
39
|
+
style.max_code_lines_in_method 3
|
40
|
+
|
41
|
+
style
|
42
|
+
end
|
43
|
+
|
44
|
+
context "single class too long" do
|
45
|
+
let(:file_name) { :method_too_long }
|
46
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
47
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "max_code_lines_in_method" }
|
48
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
49
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 0 }
|
50
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
51
|
+
end
|
52
|
+
|
53
|
+
context "method in a method" do
|
54
|
+
let(:file_name) { :method_too_long }
|
55
|
+
specify { critic.problems[file_name.to_s].size.should be 1 }
|
56
|
+
specify { critic.problems[file_name.to_s].first[:type].should == "max_code_lines_in_method" }
|
57
|
+
specify { critic.problems[file_name.to_s].first[:line].should be 1 }
|
58
|
+
specify { critic.problems[file_name.to_s].first[:column].should be 0 }
|
59
|
+
specify { critic.problems[file_name.to_s].first[:level].should be :error }
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../support/vertical_spacing_cases'
|
3
|
+
require 'tailor/critic'
|
4
|
+
require 'tailor/configuration/style'
|
5
|
+
|
6
|
+
describe "Vertical Space problem detection" do
|
7
|
+
before do
|
8
|
+
Tailor::Logger.stub(:log)
|
9
|
+
FakeFS.activate!
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:critic) do
|
13
|
+
Tailor::Critic.new
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:style) do
|
17
|
+
style = Tailor::Configuration::Style.new
|
18
|
+
style.trailing_newlines 0, level: :off
|
19
|
+
style.allow_invalid_ruby true, level: :off
|
20
|
+
|
21
|
+
style
|
22
|
+
end
|
23
|
+
|
24
|
+
V_SPACING_OK.each do |file_name, contents|
|
25
|
+
before do
|
26
|
+
FileUtils.touch file_name.to_s
|
27
|
+
File.open(file_name.to_s, 'w') { |f| f.write contents }
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be OK" do
|
31
|
+
critic.check_file(file_name.to_s, style.to_hash)
|
32
|
+
critic.problems.should == { file_name.to_s => [] }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,265 @@
|
|
1
|
+
#-------------------------------------------------------------------------------
|
2
|
+
# INDENT_1 (1 problem)
|
3
|
+
#-------------------------------------------------------------------------------
|
4
|
+
INDENT_1 = {}
|
5
|
+
|
6
|
+
INDENT_1[:class_indented_end] =
|
7
|
+
%Q{class MyClass
|
8
|
+
end}
|
9
|
+
|
10
|
+
INDENT_1[:class_indented_single_statement] =
|
11
|
+
%Q{class MyClass
|
12
|
+
include Something
|
13
|
+
end}
|
14
|
+
|
15
|
+
INDENT_1[:class_indented_single_statement_trailing_comment] =
|
16
|
+
%Q{class MyClass
|
17
|
+
include Something # comment
|
18
|
+
end}
|
19
|
+
|
20
|
+
INDENT_1[:class_outdented_single_statement] =
|
21
|
+
%Q{class MyClass
|
22
|
+
include Something
|
23
|
+
end}
|
24
|
+
|
25
|
+
INDENT_1[:def_indented_end] =
|
26
|
+
%Q{def a
|
27
|
+
end}
|
28
|
+
|
29
|
+
INDENT_1[:def_content_indented_end] =
|
30
|
+
%Q{def a
|
31
|
+
puts "stuff"
|
32
|
+
end}
|
33
|
+
|
34
|
+
INDENT_1[:class_def_content_outdented_end] =
|
35
|
+
%Q{class A
|
36
|
+
def a
|
37
|
+
puts "stuff"
|
38
|
+
end
|
39
|
+
end}
|
40
|
+
|
41
|
+
INDENT_1[:class_def_outdented_content] =
|
42
|
+
%Q{class A
|
43
|
+
def a
|
44
|
+
puts "stuff"
|
45
|
+
end
|
46
|
+
end}
|
47
|
+
|
48
|
+
INDENT_1[:class_method_def_using_self_outdented] =
|
49
|
+
%Q{class A
|
50
|
+
self.my_method
|
51
|
+
puts 'stuff'
|
52
|
+
end
|
53
|
+
end}
|
54
|
+
|
55
|
+
INDENT_1[:case_indented_whens_level] =
|
56
|
+
%Q{def my_method
|
57
|
+
case true
|
58
|
+
when true
|
59
|
+
puts "stuff"
|
60
|
+
when false
|
61
|
+
puts "blah blah"
|
62
|
+
end
|
63
|
+
end}
|
64
|
+
|
65
|
+
INDENT_1[:case_indented_whens_level_trailing_comment] =
|
66
|
+
%Q{def my_method
|
67
|
+
case true # comment
|
68
|
+
when true
|
69
|
+
puts "stuff"
|
70
|
+
when false
|
71
|
+
puts "blah blah"
|
72
|
+
end
|
73
|
+
end}
|
74
|
+
|
75
|
+
INDENT_1[:case_outdented_whens_level] =
|
76
|
+
%Q{def my_method
|
77
|
+
case true
|
78
|
+
when true
|
79
|
+
puts "stuff"
|
80
|
+
when false
|
81
|
+
puts "blah blah"
|
82
|
+
end
|
83
|
+
end}
|
84
|
+
|
85
|
+
INDENT_1[:case_when_indented_whens_level] =
|
86
|
+
%Q{def my_method
|
87
|
+
case true
|
88
|
+
when true
|
89
|
+
puts "stuff"
|
90
|
+
when false
|
91
|
+
puts "blah blah"
|
92
|
+
end
|
93
|
+
end}
|
94
|
+
|
95
|
+
INDENT_1[:case_when_outdented_whens_level] =
|
96
|
+
%Q{def my_method
|
97
|
+
case true
|
98
|
+
when true
|
99
|
+
puts "stuff"
|
100
|
+
when false
|
101
|
+
puts "blah blah"
|
102
|
+
end
|
103
|
+
end}
|
104
|
+
|
105
|
+
INDENT_1[:case_indented_whens_in] =
|
106
|
+
%Q{def my_method
|
107
|
+
case true
|
108
|
+
when true
|
109
|
+
puts "stuff"
|
110
|
+
when false
|
111
|
+
puts "blah blah"
|
112
|
+
end
|
113
|
+
end}
|
114
|
+
|
115
|
+
INDENT_1[:while_do_indented] =
|
116
|
+
%Q{ while true do
|
117
|
+
puts "something"
|
118
|
+
end}
|
119
|
+
|
120
|
+
INDENT_1[:while_do_outdented] =
|
121
|
+
%Q{def my_method
|
122
|
+
while true do
|
123
|
+
puts "something"
|
124
|
+
end
|
125
|
+
end}
|
126
|
+
|
127
|
+
INDENT_1[:while_do_content_outdented] =
|
128
|
+
%Q{def my_method
|
129
|
+
while true do
|
130
|
+
puts "something"
|
131
|
+
end
|
132
|
+
end}
|
133
|
+
|
134
|
+
INDENT_1[:while_do_content_indented] =
|
135
|
+
%Q{def my_method
|
136
|
+
while true do
|
137
|
+
puts "something"
|
138
|
+
end
|
139
|
+
end}
|
140
|
+
|
141
|
+
INDENT_1[:while_do_indented2] =
|
142
|
+
%Q{i = 0;
|
143
|
+
num = 5;
|
144
|
+
|
145
|
+
while i < num do
|
146
|
+
puts("Inside the loop i = \#{i}");
|
147
|
+
i +=1;
|
148
|
+
end}
|
149
|
+
|
150
|
+
INDENT_1[:while_do_indented2_trailing_comment] =
|
151
|
+
%Q{i = 0;
|
152
|
+
num = 5;
|
153
|
+
|
154
|
+
while i < num do # comment
|
155
|
+
puts("Inside the loop i = \#{i}");
|
156
|
+
i +=1;
|
157
|
+
end}
|
158
|
+
|
159
|
+
INDENT_1[:until_do_indented] =
|
160
|
+
%Q{i = 0;
|
161
|
+
num = 5;
|
162
|
+
|
163
|
+
until i > num do
|
164
|
+
puts("Inside the loop i = \#{i}");
|
165
|
+
i +=1;
|
166
|
+
end}
|
167
|
+
|
168
|
+
INDENT_1[:for_do_indented] =
|
169
|
+
%Q{ for i in 1..100 do
|
170
|
+
puts i
|
171
|
+
end}
|
172
|
+
|
173
|
+
INDENT_1[:loop_do_indented] =
|
174
|
+
%Q{ loop do
|
175
|
+
puts 'looping'
|
176
|
+
end}
|
177
|
+
|
178
|
+
INDENT_1[:if_line_indented] =
|
179
|
+
%Q{def a_method
|
180
|
+
if defined? Term::ANSIColor
|
181
|
+
message << %Q{# \#{(i + 1).to_s.bold}.
|
182
|
+
# * position: \#{position}
|
183
|
+
# * type: \#{problem[:type].to_s.red}
|
184
|
+
# * message: \#{problem[:message].red}
|
185
|
+
}
|
186
|
+
else
|
187
|
+
message << %Q{# \#{(i + 1)}.
|
188
|
+
# * position: \#{position}
|
189
|
+
# * type: \#{problem[:type]}
|
190
|
+
# * message: \#{problem[:message]}
|
191
|
+
}
|
192
|
+
end
|
193
|
+
end}
|
194
|
+
|
195
|
+
INDENT_1[:if_line_indented_trailing_comment] =
|
196
|
+
%Q{def a_method
|
197
|
+
if defined? Term::ANSIColor # comment
|
198
|
+
message << %Q{# \#{(i + 1).to_s.bold}.
|
199
|
+
# * position: \#{position}
|
200
|
+
# * type: \#{problem[:type].to_s.red}
|
201
|
+
# * message: \#{problem[:message].red}
|
202
|
+
}
|
203
|
+
else
|
204
|
+
message << %Q{# \#{(i + 1)}.
|
205
|
+
# * position: \#{position}
|
206
|
+
# * type: \#{problem[:type]}
|
207
|
+
# * message: \#{problem[:message]}
|
208
|
+
}
|
209
|
+
end
|
210
|
+
end}
|
211
|
+
|
212
|
+
INDENT_1[:multi_line_tstring] =
|
213
|
+
%Q{INDENT_OK[:class] =
|
214
|
+
%Q{class MyClass
|
215
|
+
end}}
|
216
|
+
|
217
|
+
#-------------------------------------------------------------------------------
|
218
|
+
# Operators
|
219
|
+
#-------------------------------------------------------------------------------
|
220
|
+
INDENT_1[:multi_line_andop_first_line_indented] =
|
221
|
+
%Q{def end_of_multiline_string?(lexed_line_output)
|
222
|
+
lexed_line_output.any? { |e| e[1] == :on_tstring_end } &&
|
223
|
+
lexed_line_output.none? { |e| e[1] == :on_tstring_beg }
|
224
|
+
end}
|
225
|
+
|
226
|
+
INDENT_1[:multi_line_andop_first_line_indented_trailing_comment] =
|
227
|
+
%Q{def end_of_multiline_string?(lexed_line_output)
|
228
|
+
lexed_line_output.any? { |e| e[1] == :on_tstring_end } && # comment
|
229
|
+
lexed_line_output.none? { |e| e[1] == :on_tstring_beg }
|
230
|
+
end}
|
231
|
+
|
232
|
+
INDENT_1[:multi_line_andop_second_line_indented] =
|
233
|
+
%Q{def end_of_multiline_string?(lexed_line_output)
|
234
|
+
lexed_line_output.any? { |e| e[1] == :on_tstring_end } &&
|
235
|
+
lexed_line_output.none? { |e| e[1] == :on_tstring_beg }
|
236
|
+
end}
|
237
|
+
|
238
|
+
INDENT_1[:multi_line_string_concat_with_plus_out] =
|
239
|
+
%Q{DVR_SSDP_NOTIFICATION_TEMPLATE = File.dirname(__FILE__) +
|
240
|
+
'/profiles/DVR5000/ssdp_notification.erb'}
|
241
|
+
|
242
|
+
INDENT_1[:multi_line_method_call_end_in] =
|
243
|
+
%Q{def initialize(raw_response)
|
244
|
+
if raw_response.nil? || raw_response.empty?
|
245
|
+
raise RTSP::Error,
|
246
|
+
"#{self.class} received nil string--this shouldn't happen."
|
247
|
+
end
|
248
|
+
end}
|
249
|
+
|
250
|
+
INDENT_1[:multi_line_method_call_ends_with_period_2nd_line_in] =
|
251
|
+
%Q{unless streamer == MulticastStreamer.instance
|
252
|
+
streamer.state = :DISCONNECTED
|
253
|
+
UnicastStreamer.pool << streamer unless UnicastStreamer.pool.
|
254
|
+
member? streamer
|
255
|
+
end}
|
256
|
+
|
257
|
+
INDENT_1[:multi_line_method_call_ends_with_many_periods_last_in] =
|
258
|
+
%Q{my_hashie.first_level.
|
259
|
+
second_level.
|
260
|
+
third_level}
|
261
|
+
|
262
|
+
INDENT_1[:multi_line_method_call_ends_with_many_periods_last_in_trailing_comment] =
|
263
|
+
%Q{my_hashie.first_level.
|
264
|
+
second_level.
|
265
|
+
third_level # comment}
|