{"id":17145962,"url":"https://github.com/soutaro/querly","last_synced_at":"2025-05-16T16:06:11.474Z","repository":{"id":48933758,"uuid":"67342015","full_name":"soutaro/querly","owner":"soutaro","description":"Query Method Calls from Ruby Programs","archived":false,"fork":false,"pushed_at":"2022-10-31T05:51:00.000Z","size":803,"stargazers_count":250,"open_issues_count":11,"forks_count":20,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-12T22:40:41.771Z","etag":null,"topics":["analysis","checker","linter","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soutaro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-04T11:53:08.000Z","updated_at":"2024-12-13T10:02:05.000Z","dependencies_parsed_at":"2022-09-11T22:02:18.921Z","dependency_job_id":null,"html_url":"https://github.com/soutaro/querly","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soutaro%2Fquerly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soutaro%2Fquerly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soutaro%2Fquerly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soutaro%2Fquerly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soutaro","download_url":"https://codeload.github.com/soutaro/querly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254564127,"owners_count":22092122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["analysis","checker","linter","ruby"],"created_at":"2024-10-14T21:07:22.791Z","updated_at":"2025-05-16T16:06:11.455Z","avatar_url":"https://github.com/soutaro.png","language":"Ruby","readme":"![Querly logo](https://github.com/soutaro/querly/blob/master/logo/Querly%20horizontal.png)\n\n# Querly - Pattern Based Checking Tool for Ruby\n\n![Ruby](https://github.com/soutaro/querly/workflows/Ruby/badge.svg)\n\nQuerly is a query language and tool to find out method calls from Ruby programs.\nDefine rules to check your program with patterns to find out *bad* pieces.\nQuerly finds out matching pieces from your program.\n\n## Overview\n\nYour project may have many local rules:\n\n* Should not use `Customer#update_mail` and use 30x faster `Customer.update_all_email` instead (Slower `#update_mail` is left just for existing code, but new code should not use it)\n* Should not use `root_url` without `locale:` parameter\n* Should not use `Net::HTTP` for Web API calls, but use `HTTPClient`\n\nThese local rule violations will be found during code review.\nReviewers will ask commiter to revise; commiter will fix; fine.\nReally?\nIt is boring and time-consuming.\nWe need some automation!\n\nHowever, that rules cannot be the standard.\nThey make sense only in your project.\nOkay, start writing a plug-in for RuboCop? (or other checking tools)\n\nInstead of writing RuboCop plug-in, just define a Querly rule in a few lines of YAML.\n\n```yml\nrules:\n  - id: my_project.use_faster_email_update\n    pattern: update_mail\n    message: When updating Customer#email, newly written code should use 30x faster Customer.update_all_email\n    justification:\n      - When you are editing old code (it should be refactored...)\n      - You are sure updating only small number of customers, and performance does not matter\n\n  - id: my_project.root_url_without_locale\n    pattern: \"root_url(!locale: _)\"\n    message: Links to top page should be with locale parameter\n\n  - id: my_project.net_http\n    pattern: Net::HTTP\n    message: Use HTTPClient to make HTTP request\n```\n\nWrite down your local rules, and let Querly check conformance with them.\nFocus on spec, design, UX, and other important things during code review!\n\n## Installation\n\nInstall via RubyGems.\n\n    $ gem install querly\n\nOr you can put it in your Gemfile.\n\n```rb\ngem 'querly'\n```\n\n## Quick Start\n\nCopy the following YAML and paste as `querly.yml` in your project's repo.\n\n```yaml\nrules:\n  - id: sample.debug_print\n    pattern:\n      - self.p\n      - self.pp\n    message: Delete debug print\n```\n\nRun `querly` in the repo.\n\n```\n$ querly check .\n```\n\nIf your code contains `p` or `pp` calls, querly will print warning messages.\n\n```\n./app/models/account.rb:44:10                  p(account.id)      Delete debug print\n./app/controllers/accounts_controller.rb:17:2  pp params: params  Delete debug print\n```\n\n## Configuration\n\nSee the following manual for configuration and query language reference.\n\n* [Configuration](https://github.com/soutaro/querly/blob/master/manual/configuration.md)\n* [Patterns](https://github.com/soutaro/querly/blob/master/manual/patterns.md)\n\nUse `querly console` command to test patterns interactively.\n\n## Requiring Rules\n\n`import` section in config file now allows accepts `require` command.\n\n```yaml\nimport:\n  - require: querly/rules/sample\n  - require: your_library/querly/rules\n```\n\nQuerly ships with `querly/rules/sample` rule set. Check `lib/querly/rules/sample.rb` and `rules/sample.yml` for detail.\n\n### Publishing Gems with Querly Rules\n\nQuerly provides `Querly.load_rule` API to allow publishing your rules as part of Ruby library.\nPut rules YAML file in your gem, and add Ruby script in some directory like `lib/your_library/querly/rules.rb`.\n\n```\nQuerly.load_rules File.join(__dir__, relative_path_to_yaml_file)\n```\n\n## Notes\n\n### Querly's analysis is syntactic\n\nThe analysis is currently purely syntactic:\n\n```rb\nrecord.save(validate: false)\n```\n\nand\n\n```rb\nx = false\nrecord.save(validate: x)\n```\n\nwill yield different results.\nThis can be improved by doing very primitive data flow analysis, and I'm planning to do that.\n\n### Too many false positives!\n\nThe analysis itself does not have very good precision.\nThere will be many false positives, and *querly warning free code* does not make much sense.\n\n* TODO: support to ignore warnings through magic comments in code\n\nQuerly is not to ensure *there is nothing wrong in the code*, but just tells you *code fragments you should review with special care*.\nI believe it still improves your software development productivity.\n\n### Incoming updates?\n\nThe following is the list of updates which would make sense.\n\n* Support for importing rule sets, and provide some good default rules\n* Support for ignoring warnings\n* Improve analysis precision by intra procedural data flow analysis\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/soutaro/querly.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoutaro%2Fquerly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoutaro%2Fquerly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoutaro%2Fquerly/lists"}