Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOREF] Add SQLFluff linter #2904

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ repos:
name: Check for committed secrets
entry: git-secrets --pre_commit_hook

- repo: https://github.com/sqlfluff/sqlfluff
rev: 3.2.5
hooks:
- id: sqlfluff-fix
exclude: ^migrations/
- id: sqlfluff-lint
exclude: ^migrations/
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I've addressed ignoring old migrations if you want to lint any new ones
CMS-Enterprise/mint-app#1538.

Note, anytime we upgrade linter versions, we likely would want to update the regex to not change indentation etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm gonna merge this PR as-is and we can loop back on enabling this for migrations later, if that's alright!

Copy link
Contributor

Choose a reason for hiding this comment

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

that's great with me!


- repo: local
hooks:
- id: remove-postman-ids
Expand Down
23 changes: 23 additions & 0 deletions .sqlfluff
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://docs.sqlfluff.com/en/stable/rules.html

[sqlfluff]
dialect = postgres
ignore = parsing
rules = core

# Ignoring capitalisation.identifiers because it seems to want to uppercase column names if there are capitalized enums defined before the table
# Ignoring layout.long_lines because we break line-length requirements in a few places with comments
# Ignoring layout.spacing since it wants to mess with variable names coming from sqlx that use the `:variablename` syntax (tries to modify them to `: variablename` with a sapce)
exclude_rules = capitalisation.identifiers, layout.long_lines, layout.spacing

[sqlfluff:rules:capitalisation.keywords]
# https://docs.sqlfluff.com/en/stable/rules.html#rule-capitalisation.keywords
capitalisation_policy = upper

[sqlfluff:rules:capitalisation.literals]
# https://docs.sqlfluff.com/en/stable/rules.html#rule-capitalisation.literals
capitalisation_policy = upper

[sqlfluff:rules:capitalisation.types]
# https://docs.sqlfluff.com/en/stable/rules.html#rule-capitalisation.types
extended_capitalisation_policy = upper
148 changes: 74 additions & 74 deletions cmd/populate_user_table/sql/get_all_full_names.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,88 +12,88 @@ accessibility_requests_and_statuses
*/
-- Sub query for actions table
-- Note, we already get the EUAID for this field, so maybe, this isn't needed
SELECT actor_name AS full_name
FROM actions
UNION
SELECT actor_name AS full_name
FROM actions
UNION

-- Sub query for business_cases table
SELECT requester AS full_name
FROM business_cases
UNION
SELECT business_owner AS full_name
FROM business_cases
UNION
-- Sub query for business_cases table
SELECT requester AS full_name
FROM business_cases
UNION
SELECT business_owner AS full_name
FROM business_cases
UNION

/* not present in these tables
cedar_system_bookmarks
estimated_lifecycle_costs
feedback_valid_source_target_combinations
flyway_schema_history
governance_request_feedback
*/
/* not present in these tables
cedar_system_bookmarks
estimated_lifecycle_costs
feedback_valid_source_target_combinations
flyway_schema_history
governance_request_feedback
*/

-- Sub query for notes table
-- Note, we already get the EUAID for this field, so maybe, this isn't needed
SELECT author_name AS full_name
FROM notes
UNION
-- Sub query for notes table
-- Note, we already get the EUAID for this field, so maybe, this isn't needed
SELECT author_name AS full_name
FROM notes
UNION

/*
system_intake_contacts
system_intake_documents
system_intake_funding_sources
*/
/*
system_intake_contacts
system_intake_documents
system_intake_funding_sources
*/

-- Sub query for system_intakes table
-- Note, we already get the EUAID, which I think we use for requester? This will have to be validated
-- Verify that these aren't duplicated from the contacts table
SELECT requester AS full_name
FROM system_intakes
UNION
SELECT business_owner AS full_name
FROM system_intakes
UNION
SELECT product_manager AS full_name
FROM system_intakes
UNION
-- Sub query for system_intakes table
-- Note, we already get the EUAID, which I think we use for requester? This will have to be validated
-- Verify that these aren't duplicated from the contacts table
SELECT requester AS full_name
FROM system_intakes
UNION
SELECT business_owner AS full_name
FROM system_intakes
UNION
SELECT product_manager AS full_name
FROM system_intakes
UNION

--TODO: NEED TO VERIFY THAT THESE FIELDS ARE NAMES AND NOT EUA IDs
SELECT isso AS full_name
FROM system_intakes
UNION
SELECT trb_collaborator AS full_name
FROM system_intakes
UNION
SELECT oit_security_collaborator AS full_name
FROM system_intakes
UNION
SELECT ea_collaborator AS full_name
FROM system_intakes
UNION
SELECT contractor AS full_name -- TODO: verify that this is meant to be an individual... This might just be a string
FROM system_intakes
UNION
SELECT isso AS full_name
FROM system_intakes
UNION
--TODO: NEED TO VERIFY THAT THESE FIELDS ARE NAMES AND NOT EUA IDs
SELECT isso AS full_name
FROM system_intakes
UNION
SELECT trb_collaborator AS full_name
FROM system_intakes
UNION
SELECT oit_security_collaborator AS full_name
FROM system_intakes
UNION
SELECT ea_collaborator AS full_name
FROM system_intakes
UNION
SELECT contractor AS full_name -- TODO: verify that this is meant to be an individual... This might just be a string
FROM system_intakes
UNION
SELECT isso AS full_name
FROM system_intakes
UNION

-- TODO: verify, is this supposed to be be the same as the other top columns
SELECT isso_name AS full_name
FROM system_intakes
UNION
SELECT trb_collaborator_name AS full_name
FROM system_intakes
UNION
SELECT oit_security_collaborator_name AS full_name
FROM system_intakes
UNION
SELECT ea_collaborator_name AS full_name
FROM system_intakes
UNION
-- TODO: verify, is this supposed to be be the same as the other top columns
SELECT isso_name AS full_name
FROM system_intakes
UNION
SELECT trb_collaborator_name AS full_name
FROM system_intakes
UNION
SELECT oit_security_collaborator_name AS full_name
FROM system_intakes
UNION
SELECT ea_collaborator_name AS full_name
FROM system_intakes
UNION

-- Unsure if this is EUAID or name, will need to verify
SELECT admin_lead AS full_name
FROM system_intakes
-- Unsure if this is EUAID or name, will need to verify
SELECT admin_lead AS full_name
FROM system_intakes
/*not present in these tables

test_dates
Expand Down
Loading