lib/scss_lint/linter/indentation.rb in scss-lint-0.23.1 vs lib/scss_lint/linter/indentation.rb in scss-lint-0.24.0

- old
+ new

@@ -1,11 +1,11 @@ module SCSSLint # Checks for consistent indentation of nested declarations and rule sets. class Linter::Indentation < Linter include LinterRegistry - def visit_root(node) + def visit_root(_node) @indent_width = config['width'] @indent = 0 yield end @@ -27,24 +27,25 @@ # sibling or its parent, as indentation isn't possible return if (previous = previous_node(node)) && previous.line == node.line actual_indent = engine.lines[node.line - 1][/^(\s*)/, 1] - if actual_indent.length != @indent - add_lint(node.line, - "Line should be indented #{@indent} spaces, " \ - "but was indented #{actual_indent.length} spaces") - return true - end + return if actual_indent.length == @indent + + add_lint(node.line, + "Line should be indented #{@indent} spaces, " \ + "but was indented #{actual_indent.length} spaces") + true end # Deal with `else` statements def visit_if(node, &block) check_and_visit_children(node, &block) visit(node.else) if node.else end # Define node types that increase indentation level + alias_method :visit_atroot, :check_and_visit_children alias_method :visit_directive, :check_and_visit_children alias_method :visit_each, :check_and_visit_children alias_method :visit_for, :check_and_visit_children alias_method :visit_function, :check_and_visit_children alias_method :visit_media, :check_and_visit_children