Skip to content

Line length checks no longer include trailing new lines in the count. #5

Merged
merged 1 commit into from Mar 6, 2012
View
2 lib/cane/style_check.rb
@@ -81,7 +81,7 @@ def spacing_conditions
# Copy of parent method using a configurable line length.
def too_long?
- length = self.length
+ length = self.chomp.length
if length > line_length_max
print_problem "Line is >#{line_length_max} characters (#{length})"
return true
View
8 spec/cane_spec.rb
@@ -54,6 +54,14 @@ def complex_method(a)
output.should include("Lines violated style requirements")
end
+ it 'does not include trailing new lines in the character count' do
+ file_name = make_file('#' * 80 + "\n" + '#' * 80)
+
+ output, exitstatus = run("--style-glob #{file_name} --style-measure 80")
+ exitstatus.should == 0
+ output.should be_empty
+ end
+
it 'allows upper bound of failed checks' do
file_name = make_file("whitespace ")
Something went wrong with that request. Please try again.