{"id":48915561,"url":"https://github.com/gildesmarais/sql_lint","last_synced_at":"2026-04-17T02:32:07.232Z","repository":{"id":305736696,"uuid":"1023791223","full_name":"gildesmarais/sql_lint","owner":"gildesmarais","description":"A lightweight SQL linter for Rails test suites, helping you catch SQL issues early with DBMS-specific rules and easy integration.","archived":false,"fork":false,"pushed_at":"2025-07-22T21:01:19.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-26T01:17:53.486Z","etag":null,"topics":["linter","performance","postgresql","ruby","sql"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gildesmarais.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-21T17:42:37.000Z","updated_at":"2025-07-22T21:01:22.000Z","dependencies_parsed_at":"2025-07-21T19:51:29.592Z","dependency_job_id":null,"html_url":"https://github.com/gildesmarais/sql_lint","commit_stats":null,"previous_names":["gildesmarais/sql_lint"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gildesmarais/sql_lint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildesmarais%2Fsql_lint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildesmarais%2Fsql_lint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildesmarais%2Fsql_lint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildesmarais%2Fsql_lint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gildesmarais","download_url":"https://codeload.github.com/gildesmarais/sql_lint/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildesmarais%2Fsql_lint/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31912373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linter","performance","postgresql","ruby","sql"],"created_at":"2026-04-17T02:32:06.526Z","updated_at":"2026-04-17T02:32:07.199Z","avatar_url":"https://github.com/gildesmarais.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SqlLint: Your SQL Quality Guardian for Rails\n\n## Catch SQL Pitfalls Early, Boost Performance, and Streamline Development\n\nSqlLint is a **minimalist, RuboCop-style SQL linter** designed to seamlessly integrate with your Rails test suite. It automatically catches common and DBMS-specific SQL pitfalls, helping you **write more robust, performant, and secure SQL queries** right when you're developing them.\n\n---\n\n## Why SqlLint? Empowering Developers with Proactive SQL Quality\n\nDatabases are critical, yet SQL-related issues often surface late in the development cycle, leading to costly fixes and performance bottlenecks. SqlLint addresses this by providing **proactive, real-time feedback** directly within your Rails test suite. This empowers you to:\n\n- **Prevent Performance Regressions**: Catch missing `LIMIT` clauses before they hit production.\n- **Avoid Data Anomalies**: Be warned about potentially unsafe `UNION` usage.\n- **Ensure Cross-DBMS Compatibility**: Leverage adapter-specific rules for PostgreSQL, MySQL, and SQLite.\n- **Streamline Code Reviews**: Automate tedious SQL review points, freeing up your team.\n- **Boost Developer Confidence**: Write SQL knowing common mistakes are being checked.\n\n---\n\n## Quick Start\n\nGetting started with SqlLint is straightforward.\n\n### Installation\n\nAdd this line to your application's `Gemfile`:\n\n```ruby\ngem 'sql_lint'\n```\n\nThen execute:\n\n```bash\nbundle install\n```\n\n### Usage\n\n1.  **Integrate with Rails:** Create an initializer file in `config/initializers/sql_lint.rb`:\n\n    ```ruby\n    # config/initializers/sql_lint.rb\n    if Rails.env.test?\n      require \"sql_lint\"\n\n      # Subscribe to Active Record's SQL notifications\n      ActiveSupport::Notifications.subscribe(\"sql.active_record\") do |_, _, _, _, payload|\n        SqlLint::Runner.run(payload[:sql])\n      end\n    end\n    ```\n\n2.  **Run Your Test Suite:** Simply execute your tests as usual (e.g., `bin/rails test`, `rspec`).\n\n    Lint warnings will appear directly in your **STDOUT**, making them easy to spot during development.\n\n---\n\n## Features at a Glance\n\nSqlLint comes packed with intelligent checks to safeguard your SQL:\n\n- **Missing `LIMIT` Detection**: Warns when `SELECT` statements might pull excessively large result sets, preventing performance hits.\n- **Unsafe `UNION` Usage**: Flags `UNION` operations that lack the `ALL` keyword, which can lead to unintended deduplication and performance overhead.\n- **Multi-DBMS Support**: Ships with robust rule sets for:\n  - **PostgreSQL**\n  - **MySQL**\n  - **SQLite**\n  - **Adapter-agnostic** (default) rules that apply across databases.\n- **Seamless Rails Integration**: Hooks directly into `ActiveRecord`'s SQL notifications, requiring minimal setup.\n- **Extensible Architecture**: Designed for growth, SqlLint makes it straightforward to add your own custom checker rules. This modularity is perfect for extending its capabilities and tailoring it to unique project needs, making it an ideal area for community contributions.\n\n---\n\n## Configuration\n\nSqlLint offers a flexible, RuboCop-inspired configuration system. Control which checks run using a `.sql_lint.yml` file at your project's root.\n\n### Example `.sql_lint.yml`\n\n```yaml\n# Disable all PostgreSQL-specific checks\nPostgreSQL:\n  Enabled: false\n\n# Disable a specific default check\nDefault/SelectWithoutLimit:\n  Enabled: false\n\n# Optimize performance by enabling parallel execution of checks\nRunner:\n  Parallel: true\n```\n\n### How Configuration Works\n\n- **Default Behavior**: All checkers are **enabled by default** for immediate comprehensive linting.\n- **Merging Logic**: Your `.sql_lint.yml` is intelligently merged with the default settings.\n- **Granular Control**:\n  - Disable **entire categories** (e.g., `PostgreSQL`, `MySQL`, `Default`) by setting `Enabled: false`.\n  - Disable **individual checkers** by their full name (e.g., `Default/SelectWithoutLimit`).\n  - Enable or disable **parallel runner execution** for faster linting on larger test suites by setting `Runner.Parallel: true`.\n- **Implicit Enablement**: If a checker or category isn't specified in your config, it remains enabled by default.\n\nThis flexible system provides **fine-grained control** over your SQL linting rules, tailored to your project's specific needs.\n\n---\n\n## Getting Started with Development\n\nReady to dive into SqlLint's codebase? Here's how to get your development environment set up quickly. You'll need Ruby 3.3.x and Docker installed.\n\n### 1. Set Up the Database and Run Tests\n\nSimply start the PostgreSQL database and run the test suite using Docker Compose. The `app` service will automatically build the Ruby environment, install dependencies, and execute the tests.\n\n```sh\ndocker compose up -d db\ndocker compose run app\n```\n\nTo run RuboCop for linting:\n\n```sh\ndocker compose run app bundle exec rubocop\n```\n\nWhen you're finished, you can stop the PostgreSQL container:\n\n```sh\ndocker compose down\n```\n\nIf you prefer to work with a shell, try:\n\n```sh\ndocker compose run --rm app /bin/bash\n```\n\n---\n\n## Contributing to SqlLint\n\nWe'd love your help to make SqlLint even better\\! Whether you're fixing bugs, adding new checker rules, improving documentation, or optimizing performance, every contribution is highly valued.\n\n- **Ideas for new checkers?** Open an issue to discuss.\n- **Want to implement a new rule?** Check out the `checkers/` directory for examples.\n- **Found a bug?** Please report it\\!\n\nFor detailed contribution guidelines, please see our [CONTRIBUTING.md](CONTRIBUTING.md) file.\n\n---\n\n## License\n\nThis project is licensed under the European Union Public License (EUPL) version 1.2. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Community \u0026 Future\n\nWe're committed to continuously improving SqlLint and welcome your involvement!\n\n- **Support**: Encounter an issue or have a question? The best way to get support is to [open an issue on GitHub](https://github.com/gildesmarais/sql_lint/issues).\n- **Roadmap \u0026 Future Ideas**: We're always looking to expand SqlLint's capabilities. Are there specific SQL patterns or DBMS quirks you'd like to see covered? Have ideas for new features or improvements? Let us know by [opening an issue](https://github.com/gildesmarais/sql_lint/issues) – your feedback shapes our future!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgildesmarais%2Fsql_lint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgildesmarais%2Fsql_lint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgildesmarais%2Fsql_lint/lists"}