Skip to content

Commit

Permalink
lint: add koyo-lint-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed Dec 21, 2024
1 parent 0051074 commit d2afd87
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 28 deletions.
80 changes: 52 additions & 28 deletions koyo-lib/blueprints/standard/app-name-here/config.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -28,67 +28,91 @@

(current-option-name-prefix "APP_NAME_HERE")

(define-option version #:default "dev")
(define-option version
#:default "dev")
(define-option debug
(equal? debug "x"))

(define-option profile
(begin0 profile
(profiler-enabled? (and profile #t))))

(define-option log-level #:default "info"
(define-option log-level
#:default "info"
(string->symbol log-level))

(define-option http-host #:default "127.0.0.1")
(define-option http-port #:default (or (getenv "PORT") "8000")
(define-option http-host
#:default "127.0.0.1")
(define-option http-port
#:default (or (getenv "PORT") "8000")
(string->number http-port))

(define-option url-scheme #:default "http"
(define-option url-scheme
#:default "http"
(begin0 url-scheme
(current-application-url-scheme url-scheme)))

(define-option url-host #:default "127.0.0.1"
(define-option url-host
#:default "127.0.0.1"
(begin0 url-host
(current-application-url-host url-host)))

(define-option url-port #:default (or (getenv "PORT") "8000")
(define-option url-port
#:default (or (getenv "PORT") "8000")
(begin0 url-port
(current-application-url-port (string->number url-port))))

(define-values (_ default-db-host default-db-port default-db-name default-db-username default-db-password)
(parse-database-url (or (getenv "DATABASE_URL") "postgres://app_name_here:app_name_here@127.0.0.1:5432/app_name_here")))

(define-option db-name #:default default-db-name)
(define-option db-username #:default default-db-username)
(define-option db-password #:default default-db-password)
(define-option db-host #:default default-db-host)
(define-option db-port #:default (number->string default-db-port)
(define-option db-name
#:default default-db-name)
(define-option db-username
#:default default-db-username)
(define-option db-password
#:default default-db-password)
(define-option db-host
#:default default-db-host)
(define-option db-port
#:default (number->string default-db-port)
(string->number db-port))

(define-option test-db-name #:default "app_name_here_tests")
(define-option test-db-username #:default "app_name_here")
(define-option test-db-password #:default "app_name_here")
(define-option test-db-host #:default "127.0.0.1")
(define-option test-db-port #:default "5432"
(define-option test-db-name
#:default "app_name_here_tests")
(define-option test-db-username
#:default "app_name_here")
(define-option test-db-password
#:default "app_name_here")
(define-option test-db-host
#:default "127.0.0.1")
(define-option test-db-port
#:default "5432"
(string->number test-db-port))

(define-option session-cookie-name #:default "_sid")
(define-option session-shelf-life #:default "86400"
(define-option session-cookie-name
#:default "_sid")
(define-option session-shelf-life
#:default "86400"
(string->number session-shelf-life))
(define-option session-secret-key-path #:default "/tmp/app-name-here-secret-key")
(define-option session-secret-key-path
#:default "/tmp/app-name-here-secret-key")
(define-option session-secret-key
(or session-secret-key (make-secret-salt/file session-secret-key-path)))

(define-option continuation-manager-memory-threshold #:default (number->string (* 1 1024 1024 1024)) ;; 1 GiB
(define-option continuation-manager-memory-threshold
#:default (number->string (* 1 1024 1024 1024)) ;; 1 GiB
(string->number continuation-manager-memory-threshold))

(define-option postmark-token)

(define-option product-name #:default "AppNameHere")
(define-option company-name #:default "AppNameHere")
(define-option company-address #:default "")
(define-option support-name #:default "Bot Botterson")
(define-option support-email #:default "support@app-name-here.com")
(define-option product-name
#:default "AppNameHere")
(define-option company-name
#:default "AppNameHere")
(define-option company-address
#:default "")
(define-option support-name
#:default "Bot Botterson")
(define-option support-email
#:default "support@app-name-here.com")

(provide common-mail-variables)
(define common-mail-variables
Expand Down
9 changes: 9 additions & 0 deletions koyo-lint-lib/info.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#lang info

(define license 'BSD-3-Clause)
(define collection "koyo")
(define deps
'("base"
"review"))
(define review-exts
'((koyo/review should-review-syntax? review-syntax)))
29 changes: 29 additions & 0 deletions koyo-lint-lib/review.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#lang racket/base

(require review/ext
syntax/parse/pre)

#|review: ignore|#

(provide
should-review-syntax?
review-syntax)

(define (should-review-syntax? stx)
(syntax-case stx (define-option)
[(define-option . _rest) #t]
[_ #f]))

(define-syntax-class option-definition
#:datum-literals (define-option)
(pattern (define-option id:id
{~optional {~seq #:default _default-expr:expression}}
{~do (push-scope)}
_body:expression ...
{~do (pop-scope)})
#:do [(track-binding #'id "~a" #:check-usages? #f)]))

(define (review-syntax stx)
(syntax-parse stx
[c:option-definition #'c]
[_ (track-error stx "expected a option definition")]))

0 comments on commit d2afd87

Please sign in to comment.