{"id":13880671,"url":"https://github.com/rubocop/vscode-rubocop","last_synced_at":"2025-04-08T17:30:38.919Z","repository":{"id":174870573,"uuid":"652910732","full_name":"rubocop/vscode-rubocop","owner":"rubocop","description":"The official VS Code extension for the RuboCop linter and code formatter.","archived":false,"fork":false,"pushed_at":"2024-05-31T02:32:03.000Z","size":1787,"stargazers_count":46,"open_issues_count":8,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-07T08:14:48.729Z","etag":null,"topics":["code-formatter","linter","rubocop","ruby","static-code-analysis","vscode-extension"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=rubocop.vscode-rubocop","language":"TypeScript","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/rubocop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["bbatsov","koic"],"patreon":"bbatsov","open_collective":"rubocop","tidelift":"rubygems/rubocop","custom":"https://www.paypal.me/bbatsov"}},"created_at":"2023-06-13T03:26:41.000Z","updated_at":"2024-07-24T15:08:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"2aa05315-eea1-4542-989b-ef4b0ac7da32","html_url":"https://github.com/rubocop/vscode-rubocop","commit_stats":null,"previous_names":["koic/vscode-rubocop","rubocop/vscode-rubocop"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubocop%2Fvscode-rubocop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubocop%2Fvscode-rubocop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubocop%2Fvscode-rubocop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubocop%2Fvscode-rubocop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubocop","download_url":"https://codeload.github.com/rubocop/vscode-rubocop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223336599,"owners_count":17128784,"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":["code-formatter","linter","rubocop","ruby","static-code-analysis","vscode-extension"],"created_at":"2024-08-06T08:03:22.350Z","updated_at":"2025-04-08T17:30:38.912Z","avatar_url":"https://github.com/rubocop.png","language":"TypeScript","funding_links":["https://github.com/sponsors/bbatsov","https://github.com/sponsors/koic","https://patreon.com/bbatsov","https://opencollective.com/rubocop","https://tidelift.com/funding/github/rubygems/rubocop","https://www.paypal.me/bbatsov"],"categories":["TypeScript"],"sub_categories":[],"readme":"# vscode-rubocop\n\n[![vscode-rubocop](https://img.shields.io/badge/-Visual%20Studio%20Code-007ACC.svg?logo=visual-studio-code\u0026style=flat)](https://marketplace.visualstudio.com/items?itemName=rubocop.vscode-rubocop)\n[![Build Status](https://github.com/rubocop/vscode-rubocop/actions/workflows/main.yml/badge.svg)](https://github.com/rubocop/vscode-rubocop/actions/workflows/main.yml)\n\nThis is the official VS Code extension for [RuboCop](https://github.com/rubocop/rubocop).\n\nYou can install this VS Code extension from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=rubocop.vscode-rubocop).\n\nFor VS Code-based IDEs like VSCodium or Eclipse Theia, the extension can be installed from the [Open VSX Registry](https://open-vsx.org/extension/rubocop/vscode-rubocop).\n\n## Language Server Capabilities\n\nThese are the capabilities of this extension, each enabled by RuboCop's [built-in LSP server](https://docs.rubocop.org/rubocop/usage/lsp.html).\n\nIt supports the following capabilities:\n\n- Fast Diagnostics (Linting)\n- Fast Document Formatting\n- Execute Command ([Trigger autocorrect](https://github.com/rubocop/vscode-rubocop#manually-triggering-a-format-with-autocorrects))\n\n:star2: **Pro tip**: Enabling [**Format On Save**](https://github.com/rubocop/vscode-rubocop#editorformatonsave) is recommended.\nBy activating just this one setting, code gets autocorrected every time a file is saved. Don't miss out on this game-changing boost to your development experience!\n\n## Requirements\n\n* [RuboCop](https://rubygems.org/gems/rubocop) 1.53.0+\n* [VS Code](https://code.visualst) 1.75.0+\n\n## Configuration\n\nThe extension only offers a few of its own configuration options, but because it conforms to\nthe [VS Code Formatting API](https://code.visualstudio.com/blogs/2016/11/15/formatters-best-practices#_the-formatting-api),\nseveral general editor settings can impact the extension's behavior as well.\n\n## Configuring the VS Code editor to use RuboCop\n\nThere are two general editor settings that you'll want to verify are set in\norder to use RuboCop as your formatter.\n\n### editor.formatOnSave\n\nTo automatically format your Ruby with RuboCop, check **Format on Save** in the\n**Formatting** settings under **Text Editor**:\n\n![Format a file on save. A formatter must be available, the file must not be saved after delay, and the editor must not be shutting down.](/docs/format-on-save.png)\n\nOr, in `settings.json`:\n\n```json\n\"editor.formatOnSave\": true,\n```\n\n### editor.defaultFormatter\n\nNext, if you have installed multiple extensions that provide formatting for Ruby\nfiles (it's okay if you're not sure—it can be hard to tell), you can specify\nRuboCop as your formatter of choice by setting `editor.defaultFormatter` under\na `\"[ruby]\"` section of `settings.json` like this:\n\n```json\n\"[ruby]\": {\n  \"editor.defaultFormatter\": \"rubocop.vscode-rubocop\"\n},\n```\n\n## Configuring RuboCop extension options\n\nTo edit RuboCop's own options, first expand **Extensions** and select\n**RuboCop** from the sidebar of the Settings editor.\n\n### rubocop.mode\n\nThe Mode setting determines how (and whether) RuboCop runs in a given\nworkspace. Generally, it will try to execute `rubocop` via `bundle exec` if\npossible, and fall back on searching for a global `rubocop` bin in your `PATH`.\n\n![Enable RuboCop via the workspace's Gemfile or else fall back on a global installation unless a Gemfile is present and its bundle does not include rubocop](/docs/mode.png)\n\n* _\"Always run—whether via Bundler or globally\"_ (JSON: `enableUnconditionally`)\n  this mode will first attempt to run via Bundler, but if that fails for any\n  reason, it will attempt to run `rubocop` in your PATH\n* **[Default]** _\"Run unless the bundle excludes rubocop\"_ (JSON:\n  `enableViaGemfileOrMissingGemfile`) this mode will attempt to run RuboCop via\n  Bundler, but if a bundle exists and the `rubocop` gem isn't in it (i.e. you're\n  working in a project doesn't use RuboCop), the extension will disable itself.\n  If, however, no bundle is present in the workspace, it will fall back on the\n  first `rubocop` executable in your PATH\n* _\"Run only via Bundler, never globally\"_ (JSON: `enableViaGemfile`) the same as\n  the default `enableViaGemfileOrMissingGemfile`, but will never run\n  `rubocop` from your PATH (as a result, single-file windows and workspace\n  folders without a Gemfile may never activate the extension)\n* _\"Run only globally, never via Bundler\"_ (JSON: `onlyRunGlobally`) if you want\n  to avoid running the bundled version of RuboCop, this mode will never\n  interact with Bundler and will only run `rubocop` on your PATH\n* _\"Disable the extension\"_ (JSON: `disable`) disable the extension entirely\n\nOr, in `settings.json`:\n\n```json\n\"rubocop.mode\": \"enableViaGemfile\",\n```\n\n### rubocop.autocorrect\n\nThe autocorrect option does what it says on the tin. if you don't want RuboCop to\nautomatically edit your documents on save, you can disable it here:\n\n![Autocorrect](/docs/autocorrect.png)\n\nYou might want to disable this if you're using RuboCop to highlight problems\nbut don't want it to edit your files automatically. You could also accomplish\nthis by disabling `editor.formatOnSave`, but as that's a global setting across\nall languages, it's more straightforward to uncheck this extension setting.\n\nOr, in `settings.json`:\n\n```json\n\"rubocop.autocorrect\": true,\n```\n\n### rubocop.safeAutocorrect\n\n**This feature requires RuboCop 1.54+ to be enabled.**\n\nWhen autocorrect is enabled, `safeAutocorrect` controls its safety. By default,\nit is enabled to perform safe autocorrections. If you disable it, unsafe\nautocorrections will also be performed, you can disable it here:\n\n![SafeAutocorrect](/docs/safe-autocorrect.png)\n\nOr, in `settings.json`:\n\n```json\n\"rubocop.safeAutocorrect\": false,\n```\n\n### rubocop.lintMode\n\n**This feature requires RuboCop 1.55+ to be enabled.**\n\nRun lint only cops (`rubocop -l`). If you only want to enable the feature as a linter like `ruby -w`,\nyou can conveniently set it here:\n\n![LintMode](/docs/lint-mode.png)\n\nOr, in `settings.json`:\n\n```json\n\"rubocop.lintMode\": true,\n```\n\n### rubocop.layoutMode\n\n**This feature requires RuboCop 1.55+ to be enabled.**\n\nRun layout only cops. If you only want to enable the feature as a formatter,\nyou can conveniently set it here:\n\n![LayoutMode](/docs/layout-mode.png)\n\nOr, in `settings.json`:\n\n```json\n\"rubocop.layoutMode\": true,\n```\n\nFurthermore, enabling autocorrect with the `editor.formatOnSave` to the effect of\n`rubocop -x` command line option.\n\n### rubocop.commandPath\n\nAs described above, the extension contains logic to determine which version of\n`rubocop` to launch. If you want a specific binary to run instead, you can\nset it here.\n\n![Command Path](/docs/command-path.png)\n\nThis will override whatever search strategy is set in `rubocop.mode`\n(except for `disable`, in which case the extension will remain disabled).\n\nOr, in `settings.json`:\n\n```json\n{\n  \"rubocop.commandPath\": \"${userHome}/.rbenv/shims/rubocop\"\n}\n```\n\n### rubocop.yjitEnabled\n\nThis extension supports YJIT, which can speed up the built-in language server in RuboCop.\nThe `rubocop.yjitEnabled` option is enabled by default.\n\n![YJIT Enabled](/docs/yjit-enabled.png)\n\nYou can disable YJIT by unchecking.\n\nOr, in `settings.json`:\n\n```json\n\"rubocop.yjitEnabled\": false\n```\n\n### rubocop.additionalLanguages\n\nThis extension is enabled by default only for files that VS Code recognizes as **ruby** files.\n\nYou can enable this extension for non-Ruby files as well using the `rubocop.additionalLanguages` option. By default, it is empty `[]`.\n\nThis extension can be enabled not only for the default `ruby` files but also for `markdown` or `erb` files.\n\n![Additional Languages](/docs/additional-languages.png)\n\nOr, in `settings.json`:\n\n```json\n\"rubocop.additionalLanguages\": [\"markdown\", \"erb\"]\n```\n\n### Changing settings only for a specific project\n\nYou may want to apply certain settings to a specific project, which you can do\nby configuring them in the [Workspace scope](https://code.visualstudio.com/docs/getstarted/settings#_workspace-settings)\nas opposed to the global User scope.\n\n![Workspace scope](/docs/workspace.png)\n\nClicking \"Workspace\" before changing a setting will save it to\n`.vscode/settings.json` inside the root workspace directory and will not affect\nthe extension's behavior in other workspace folders.\n\n## Manually triggering a format with autocorrects\n\nIn addition to the built-in VS Code Formatting API, you can trigger the\nextension to format and autocorrect the current file listing by running\nthe command \"RuboCop: Format with Autocorrects\". This is equivalent to `rubocop -a`:\n\n![Autocorrect command](/docs/autocorrect-command.png)\n\nThis is handy if you don't want to enable format-on-save, already have another\nformatter associated with Ruby files, want to format your code _before_ saving,\nor just want to bind a shortcut to RuboCop's formatting action.\n\nTo map a keybind to the command, search for it by name in the [Keyboard Shortcuts\neditor](https://code.visualstudio.com/docs/getstarted/keybindings#_keyboard-shortcuts-editor):\n\n![Keybinding](/docs/keybind.png)\n\nOr, in `keybindings.json`:\n\n```json\n[\n  {\n    \"key\": \"ctrl+alt+cmd+f\",\n    \"command\": \"rubocop.formatAutocorrects\"\n  }\n]\n```\n\nYou can also trigger the extension to format and autocorrect all the current file listing by running\nthe command \"RuboCop: Format All with Autocorrects\". This is equivalent to `rubocop -A`:\n\n![Autocorrect all command](/docs/autocorrect-all-command.png)\n\n**This command \"RuboCop: Format All with Autocorrects\" requires RuboCop 1.56+ to be enabled.**\n\nYou can use two autocorrect commands depending on the purpose.\n\n## Decoding the Status Bar item\n\nThe extension also includes a status bar item to convey the status of the\ncurrent file listing at a glance.\n\nWhen the file conforms to RuboCop without issue:\n\n![Status: no issues](/docs/status-ok.png)\n\nWhen the file contains a low-severity formatting issue:\n\n![Status: info](/docs/status-info.png)\n\nWhen the file contains a normal linter error:\n\n![Status: info](/docs/status-warn.png)\n\nWhen the file fails to parse at all:\n\n![Status: parse failure](/docs/status-parse-fail.png)\n\nClicking the status bar item will open the problems tab:\n\n![Problems tab](/docs/problems.png)\n\n## Limitations\n\nThere's some room for improvement yet, but it isn't yet clear whether these\nlimitations will be a big deal in practice:\n\n* The extension will only launch a single instance of `rubocop --lsp` per\n  workspace. If you're using a [multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces),\n  they'll all be handled by whatever RuboCop version is found in the first one\n* RuboCop's LSP only supports \"Full\" [text document synchronization](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_synchronization),\n  both because it seemed hard to implement incremental sync correctly and\n  because attempting to pass RuboCop's runner a partial document would result in\n  inconsistent formatting results\n\n## Acknowledgements\n\nThis extension's codebase was initially based on [Standard Ruby](https://github.com/standardrb)'s\n[vscode-standard-ruby](https://github.com/standardrb/vscode-standard-ruby) and\n[Kevin Newton](https://github.com/kddnewton)'s [vscode-syntax-tree](https://github.com/ruby-syntax-tree/vscode-syntax-tree)\nextension, which has a similar architecture (VS Code language client\ncommunicating with a long-running Ruby process via STDIO). Thank you!\n\n## Code of Conduct\n\nThis project follows The RuboCop Community [Code of Conduct](https://github.com/rubocop/rubocop/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubocop%2Fvscode-rubocop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubocop%2Fvscode-rubocop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubocop%2Fvscode-rubocop/lists"}