lint: convert snake to camel case
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
"git.offline-twitter.com/offline-labs/gas-stack/pkg/schema/lint"
|
||||
)
|
||||
|
||||
var sqlite_lint = &cobra.Command{
|
||||
var sqliteLint = &cobra.Command{
|
||||
Use: "sqlite_lint <path/to/schema.sql>",
|
||||
Short: "Lint a SQLite schema",
|
||||
|
||||
@@ -32,18 +32,18 @@ var sqlite_lint = &cobra.Command{
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
is_failure := false
|
||||
isFailure := false
|
||||
// Execute each check against the database
|
||||
for _, check := range lint.Checks {
|
||||
// Checks can be disabled via Github config / environment variables
|
||||
if !is_check_enabled(check) {
|
||||
if !isCheckEnabled(check) {
|
||||
continue
|
||||
}
|
||||
results := check.Execute(schema)
|
||||
|
||||
// If there are results, print them as lint errors
|
||||
if len(results) > 0 {
|
||||
is_failure = true
|
||||
isFailure = true
|
||||
fmt.Printf(RED+"Check '%s' failed:\n"+RESET, check.Name)
|
||||
for _, result := range results {
|
||||
fmt.Printf(RED+"- %s: %s.%s\n"+RESET, result.ErrorMsg, result.TableName, result.ColumnName)
|
||||
@@ -51,7 +51,7 @@ var sqlite_lint = &cobra.Command{
|
||||
fmt.Printf(RED+"Explanation: %s\n\n"+RESET, check.Explanation)
|
||||
}
|
||||
}
|
||||
if is_failure {
|
||||
if isFailure {
|
||||
fmt.Println(RED + "Errors found" + RESET)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -61,16 +61,16 @@ var sqlite_lint = &cobra.Command{
|
||||
|
||||
// github_actions_input_env_var converts an input name to the corresponding
|
||||
// environment variable name used by GitHub Actions.
|
||||
func github_actions_input_env_var(name string) string {
|
||||
func githubActionsInputEnvVar(name string) string {
|
||||
// GitHub normalizes both hyphens and underscores to underscores, then uppercases the name
|
||||
normalized := strings.NewReplacer("-", "_", " ", "_").Replace(name)
|
||||
return "INPUT_" + strings.ToUpper(normalized)
|
||||
}
|
||||
|
||||
// Setting the environment variable INPUT_REQUIRE_NOT_NULL="false" disables the "require_not_null" check
|
||||
func is_check_enabled(c lint.Check) bool {
|
||||
val, is_set := os.LookupEnv(github_actions_input_env_var(c.Name))
|
||||
if !is_set {
|
||||
func isCheckEnabled(c lint.Check) bool {
|
||||
val, isSet := os.LookupEnv(githubActionsInputEnvVar(c.Name))
|
||||
if !isSet {
|
||||
// Enable all checks by default
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user