src/sqlfluff/core/rules/std.py
def _eval(self, segment, raw_stack, **kwargs):
        """Incorrect indentation found in file."""
        tab = "\t"
        space = " "
        correct_indent = (
            space * self.tab_space_size if self.indent_unit == "space" else tab
        )
        wrong_indent = (
            tab if self.indent_unit == "space" else space * self.tab_space_size
        )
        if segment.is_type("whitespace") and wrong_indent in segment.raw:
            description = "Incorrect indentation type found in file."
            edit_indent = segment.raw.replace(wrong_indent, correct_indent)
            # Ensure that the number of space indents is a multiple of tab_space_size
            # before attempting to convert spaces to tabs to avoid mixed indents
            # unless we are converted tabs to spaces (indent_unit = space)
            if (
                (
                    self.indent_unit == "space"
                    or segment.raw.count(space) % self.tab_space_size == 0
                )
                # Only attempt a fix at the start of a newline for now
                and (len(raw_stack) == 0 or raw_stack[-1].is_type("newline"))
            ):
                fixes = [
                    LintFix(
                        "edit",
                        segment,
                        self.make_whitespace(
                            raw=edit_indent,
                            pos_marker=segment.pos_marker,
                        ),
                    )
                ]
            else:
                description += " No fix available as number of spaces in indent is not a multiple of tab_space_size."
                fixes = []
            return LintResult(anchor=segment, fixes=fixes, description=description)
Incorrect indentation found in file.
Incorrect indentation found in file.
Incorrect indentation found in file .
def _eval(self, segment, raw_stack, **kwargs):
        tab = "\t"
        space = " "
        correct_indent = (
            space * self.tab_space_size if self.indent_unit == "space" else tab
        )
        wrong_indent = (
            tab if self.indent_unit == "space" else space * self.tab_space_size
        )
        if segment.is_type("whitespace") and wrong_indent in segment.raw:
            description = "Incorrect indentation type found in file."
            edit_indent = segment.raw.replace(wrong_indent, correct_indent)
            if (
                (
                    self.indent_unit == "space"
                    or segment.raw.count(space) % self.tab_space_size == 0
                )
                and (len(raw_stack) == 0 or raw_stack[-1].is_type("newline"))
            ):
                fixes = [
                    LintFix(
                        "edit",
                        segment,
                        self.make_whitespace(
                            raw=edit_indent,
                            pos_marker=segment.pos_marker,
                        ),
                    )
                ]
            else:
                description += " No fix available as number of spaces in indent is not a multiple of tab_space_size."
                fixes = []
            return LintResult(anchor=segment, fixes=fixes, description=description)
def _eval ( self , segment , raw_stack , ** kwargs ) : tab = "\t" space = " " correct_indent = ( space * self . tab_space_size if self . indent_unit == "space" else tab ) wrong_indent = ( tab if self . indent_unit == "space" else space * self . tab_space_size ) if segment . is_type ( "whitespace" ) and wrong_indent in segment . raw : description = "Incorrect indentation type found in file." edit_indent = segment . raw . replace ( wrong_indent , correct_indent ) if ( ( self . indent_unit == "space" or segment . raw . count ( space ) % self . tab_space_size == 0 ) and ( len ( raw_stack ) == 0 or raw_stack [ - 1 ] . is_type ( "newline" ) ) ) : fixes = [ LintFix ( "edit" , segment , self . make_whitespace ( raw = edit_indent , pos_marker = segment . pos_marker , ) , ) ] else : description += " No fix available as number of spaces in indent is not a multiple of tab_space_size." fixes = [ ] return LintResult ( anchor = segment , fixes = fixes , description = description )
Incorrect indentation found in file.
Incorrect indentation found in file .
"""Incorrect indentation found in file.""" # Ensure that the number of space indents is a multiple of tab_space_size # before attempting to convert spaces to tabs to avoid mixed indents # unless we are converted tabs to spaces (indent_unit = space) # Only attempt a fix at the start of a newline for now
self
segment
raw_stack