Skip to content

Extend TextBlockGoogleStyleFormatting to check indentation of each line in the blocks #18227

@mohitsatr

Description

@mohitsatr

Follow-up of #17329

From docs:
https://google.github.io/styleguide/javaguide.html#s4.8.9-text-blocks

Each line of text in the text block is indented at least as much as the opening and closing """.

Currently, this check covers:

We need to extend the check to add support for checking the indentation of each line between the quotes.

Invalid cases:

        final String simpleScript =
            """
     Less Indentation than expected
     Violation is expected here.              
            """; // VIOLATION EXPECTED ABOVE
        final String simpleScript =
            """
     Less Indentation than expected
                and each line has a different indentation value
                        Violation is expected here.                  
            """;        // VIOLATION EXPECTED ABOVE

Valid cases:

        final String simpleScript =
"""
            More indentation than the quotes, ok
""";
        final String simpleScript =simpleScript3.endsWith(                           
                """                                           
                This is a simple sentence                     
                    This is a simple sentence                 
                       This is a simple sentence              
                """);                                         
        final String simpleScript =
            """
            indentation is same as the quotes, ok
            """;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions