Skip to content

ucg8j/gsl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gsl

go-sql-linter | good-sql-looks

Dev

# build
$ go build -o gsl main.go
# test
$ gsl lint example/test.sql

TODOs

cmd

  • error if filename not .sql
  • overwrite previous file
  • take multiple files could be gsl file1 file2 or gsl . with an -r flag for recursive

lint rules

  • Trailing Whitespace
  • Greater than one newline
  • capitalisation of SQL keywords
    • Bug: doesn't work if keyword has delimiter , immediately before/after keyword
    • Bug: doesn't work if keyword is a function e.g. if(a...
  • detecting nested queries
  • 2 spaces for indentation. Not tabs.
  • blank line between groups of logic e.g after a select statement, after a from, after Joins etc

Optimisations

  • each lint rule/function loops through lines of the .sql file. Whilst this is O(N), once there are a many of rules e.g. 10 the speed could noticeably be increased
  • the in-memory impact of a sql file or several variants is likely very small, however optimisation using pointers could make this even more light weight.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages