lib/scss_lint/linter/shorthand.rb in scss-lint-0.20.3 vs lib/scss_lint/linter/shorthand.rb in scss-lint-0.21.0
- old
+ new
@@ -61,21 +61,29 @@
"written more concisely as `#{shortest_form.join(' ')}` " <<
"instead of `#{values.join(' ')}`")
end
def condensed_shorthand(top, right, bottom = nil, left = nil)
- if top == right && right == bottom && bottom == left
+ if can_condense_to_one_value(top, right, bottom, left)
[top]
- elsif top == right && bottom.nil? && left.nil?
- [top]
- elsif top == bottom && right == left
+ elsif can_condense_to_two_values(top, right, bottom, left)
[top, right]
- elsif top == bottom && left.nil?
- top == right ? [top] : [top, right]
elsif right == left
[top, right, bottom]
else
[top, right, bottom, left].compact
end
+ end
+
+ def can_condense_to_one_value(top, right, bottom, left)
+ if top == right
+ top == bottom && (bottom == left || left.nil?) ||
+ bottom.nil? && left.nil?
+ end
+ end
+
+ def can_condense_to_two_values(top, right, bottom, left)
+ top == bottom && right == left ||
+ top == bottom && left.nil? && top != right
end
end
end