Skip to content

Conversation

WittierDinosaur
Copy link
Contributor

@WittierDinosaur WittierDinosaur commented Apr 24, 2024

Brief summary of the change made

Function names shouldn't have touch after, function parameters should have touch before - as functions can be bare.
Fixes #5808
Fixes #5869
Fixes #5978

Are there any other side effects of this change that we should be aware of?

Hopefully no knock on effects. I reckon now that we have the function_contents segment, a few rules can be rewritten in a more elegant way - but this PR is already crowded enough. It may be worth a minor release due to the sheer size of the code change.

Pull Request checklist

  • Please confirm you have completed any of the necessary steps below.

  • Included test cases to demonstrate any code changes, which may be one or more of the following:

    • .yml rule test cases in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

Copy link
Contributor

github-actions bot commented Aug 25, 2024

Coverage Results ✅

Name    Stmts   Miss  Cover   Missing
-------------------------------------
TOTAL   18078      0   100%

228 files skipped due to complete coverage.

@WittierDinosaur WittierDinosaur changed the title Fix alignment rules of functions in default config Fix spacing rules for functions Aug 25, 2024
Copy link
Contributor

@keraion keraion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall things look good, some very nice clean up. There are a few parse_mode lines left in commented out that could be removed. The Sequence(Bracketed(...)) pattern feels redundant, but that's more of a preference thing.

optional=True,
),
),
# parse_mode=ParseMode.GREEDY,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented line can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed on these, will sort tomorrow


type = "function_contents"

match_grammar = Sequence(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Sequence is not required here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting quirk that we should probably fix. You cannot start a match grammar with Bracketed(). The sequence wrapping allows it to work, OneOf, AnyOf, etc would also work. It you remove the Sequence here, it breaks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that is interesting.

# The brackets might be empty for some functions...
optional=True,
),
# parse_mode=ParseMode.GREEDY,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented line.

"FunctionContentsGrammar",
),
),
# parse_mode=ParseMode.GREEDY,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented line.

WittierDinosaur and others added 2 commits August 26, 2024 12:24
Co-authored-by: Cameron <105471409+keraion@users.noreply.github.com>
Copy link
Contributor

@OTooleMichael OTooleMichael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@keraion keraion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the change this LGTM!

@WittierDinosaur WittierDinosaur added this pull request to the merge queue Aug 28, 2024
Merged via the queue into main with commit 18293ce Aug 28, 2024
32 checks passed
@WittierDinosaur WittierDinosaur deleted the bugfix-postgres-bare-function-spacing branch August 28, 2024 10:12
@WittierDinosaur WittierDinosaur added minor release A PR or issue queued for minor release. labels Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor release A PR or issue queued for minor release.
Projects
None yet
3 participants