Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker Support #182

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
103 changes: 0 additions & 103 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,103 +0,0 @@
# 0.8.6

- Info level cops are displayed as info level
- (internal) eliminate deprecated API

# 0.8.5

- work with rubocop over 0.90

# 0.8.4

- Ignore warnings and proceed if there is valid rubocop output
- fix test

# 0.8.3

- Using relative config file path

# 0.8.2

- update packages that have secirity issues

# 0.8.1

- add `suppressRubocopWarnings` option that ignore warning

# 0.8.0

- add useBundler config. We can set `true` to override to `bundle exec rubocop`

# 0.7.1

- Fix autoCorrection find on windows

# 0.7.0

- Fix autocorrect was not respecting the .rubocop.yml

# 0.6.1

- Accepts a command is prefixed like 'bundle exec'

# 0.6.0

- Set autocorrect as a formatter

# 0.5.0

- Automatically detect and use bundled rubocop

# 0.4.0

- Lint files opened before the extension is loaded.
- Don't clear diagnostics of other files.
- Kill running rubocop process on close a file.
- Run single process at a time (to avoid accidental process bomb) (using queue).
- This is caused by vscode's project-wide replace (opens all matched file at once).

# 0.3.5

- force `force-exclude` option

# 0.3.4

- don't execute when starting git diff mode

# 0.3.3

- output error when stderr presented
- show specific error message for empty output (to identify problem)

# 0.3.2

- execute on open

# 0.3.1

- Rubocop saves the file before correcting it and runs checks again

# 0.3.0

- Add auto correct command
- display message when config file is not exist

# 0.2.2

- show message when occur errors on parsing JSON

# 0.2.1

- find rubocop from PATH

# 0.2.0

- enable specify config file (e.g. .rubocop.yml)

# 0.1.11

- show warning when rubocop output is empty

# 0.1.10

- handling JSON syntax error
141 changes: 34 additions & 107 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,110 +1,37 @@
# Rubocop for Visual Studio Code
# Docker-Ruby-Rubocop
### Liniting as per your convenience

![travis status](https://travis-ci.org/misogi/vscode-ruby-rubocop.svg?branch=master)

Visual Studio Code で rubocop を実行するエクステンションです。

This extension provides interfaces to rubocop for vscode.

[rubocop](https://github.com/bbatsov/rubocop) is a code analyzer for ruby.

[ruby rubocop in Code Market Place](https://marketplace.visualstudio.com/items/misogi.ruby-rubocop)

![exec on save](./images/onsave.gif)

## Problems

This extension may have problems when using a rvm or chruby environment.
We recommend [vscode-ruby](https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby). It can also lint ruby code.

When autoCorrect is enabled, the history of changing file is broken.
Docker-Ruby-Rubocop is a VSCode etension that lets you lint ruby files using rubocop on system and rubocop running inside docker containers.

## Features

- lint by executing the command "Ruby: lint by rubocop" (cmd+shift+p and type command)
- auto invoke when saving file
- auto correct command "Ruby: autocorrect by rubocop"

### Exclude file

The extension forces rubocop's `force-exclusion` option.

If you do not want rubocop to be executed on some file, you can add AllCops/Exclude in rubocop.yml. The file can be saved without executing rubocop.

# Installation

Installation of ruby and rubocop is required.

```
gem install rubocop
```

- Type F1 (or Command + Shift + P)
- execute "Extensions: install extension"
- type rubocop and execute `ext install ruby-rubocop`

If VSCode market place is not configured in your FLOSS distribution of code (you have Open VSX instead):

1. Go on [VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=misogi.ruby-rubocop) and clic on the [Download Extension](https://marketplace.visualstudio.com/_apis/public/gallery/publishers/misogi/vsextensions/ruby-rubocop/0.8.5/vspackage) button.
2. Install the extension manually from the CLI: `code --install-extension misogi.ruby-rubocop-0.8.5.vsix`

# ChangeLog

[ChangeLog](CHANGELOG.md)

## Configuration

Specify configuration (via navigating to `File > Preferences > Workspace Settings` and editing file `settings.json):`

```javascript
{
// If not specified searches for 'rubocop' executable available on PATH (default and recommended)
"ruby.rubocop.executePath": "",

// You can use specific path
// "ruby.rubocop.executePath": "/Users/you/.rbenv/shims/"
// "ruby.rubocop.executePath": "/Users/you/.rvm/gems/ruby-2.3.2/bin/"
// "ruby.rubocop.executePath": "D:/bin/Ruby22-x64/bin/"

// If not specified, it assumes a null value by default.
"ruby.rubocop.configFilePath": "/path/to/config/.rubocop.yml",

// default true
"ruby.rubocop.onSave": true
}
```

### Keybindings

You can change the keybinding (via editing `keybindings.json`)

```javascript
{ "key": "ctrl+alt+l", "command": "ruby.rubocopAutocorrect",
"when": "editorLangId == 'ruby'" }
```

# todo

- more configurable command line options (like -R)
- integration with rbenv
- testing & CI support

# Contribute with this extension

Please install packages with yarn.

yarn install

You could install TSLint extension for .ts files.

Please format code using prettier.

```
yarn prettier src/* test/* --write
```

# License

このソフトウェアは MIT ライセンスの元で公開されています。[LICENSE.txt](LICENSE.txt) をご覧下さい。

This software is released under the MIT License, see [LICENSE.txt](LICENSE.txt).
___
- Execute Rubocop inside docker or in the host machine
- Get Lint output for files with large number of lines


## A Note of Gratitude
___
This extension is created by forking a good plugin name ruby-rubocop create by the man [misogi](https://github.com/misogi?tab=overview). Misogi have have provided the ruby commuity with a good linting plugin for years. His code heped me a lot while building this plugin. So, **a big thanks to the friend I have never met** 🤝🏽.

## Installation and Setup
___
1. Go to Vscode Extensions Tab
2. Search for Docker-Ruby-Rubocop
3. Click on the extension made by s035 and install.

Open Extension's Setting and follow the below steps for respective modes.
#### Setup for using rubocop on docker (Docker Mode)
- check the "useDocker" checkbox.
- check the "disableEmptyFileCop" checkbox (if you enable this, you will receive an Lint/EmptyfileCop offence when linitng the files which are not present inside the docker container.)
- If you have an rubocop config file inside the docker, please specify the rubocop config file path inside the docker container.
#### Setup for using rubocop on system (Normal Mode)
- Uncheck the useDocker checkbox.
- Uncheck the disableEmptyFileCop.
- Provide the path where rubocop is available in the Execution Path Input Box.
- Provide the path for rubocop config file on system, if rubocop config file is available.

If you want rubocop to be ran on every save, check the execute on save checkbox.

### Issues
___
If you face any issues or problemswhen using the extension, please feel free to create an issue.
Binary file added images/logo.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/onsave.gif
Binary file not shown.
Binary file removed images/rubocop.png
Binary file not shown.
45 changes: 30 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"name": "ruby-rubocop",
"version": "0.8.6",
"publisher": "misogi",
"displayName": "ruby-rubocop",
"description": "execute rubocop for current Ruby code.",
"name": "docker-ruby-rubocop",
"version": "0.3.0",
"publisher": "s035",
"displayName": "docker-ruby-rubocop",
"description": "Lint Rubycode use your local eubocop and rubocop on docker",
"engines": {
"vscode": "^1.62.0"
},
"icon": "images/rubocop.png",
"icon": "images/logo.jpg",
"repository": {
"type": "git",
"url": "https://github.com/misogi/vscode-ruby-rubocop.git"
"url": "https://github.com/suryanarayanan035/docker-ruby-rubocop.git"
},
"categories": [
"Programming Languages",
"Linters"
],
"activationEvents": [
"onLanguage:ruby",
"onCommand:ruby.rubocop"
"onCommand:docker-ruby.rubocop"
],
"main": "./out/src/extension",
"scripts": {
Expand Down Expand Up @@ -47,7 +47,7 @@
],
"commands": [
{
"command": "ruby.rubocop",
"command": "docker-ruby.rubocop",
"title": "Ruby: lint by rubocop"
},
{
Expand All @@ -64,32 +64,47 @@
],
"configuration": {
"type": "object",
"title": "Ruby-Rubocop configuration",
"title": "Docker-Ruby-Rubocop configuration",
"properties": {
"ruby.rubocop.executePath": {
"docker-ruby.rubocop.executePath": {
"type": "string",
"default": "",
"description": "execution path of rubocop."
},
"ruby.rubocop.configFilePath": {
"docker-ruby.rubocop.configFilePath": {
"type": "string",
"default": "",
"description": "Filepath to the configuration file for Rubocop"
},
"ruby.rubocop.onSave": {
"docker-ruby.rubocop.onSave": {
"type": "boolean",
"default": true,
"description": "execute rubocop on save."
},
"ruby.rubocop.useBundler": {
"docker-ruby.rubocop.useBundler": {
"type": "boolean",
"default": false,
"description": "execute rubocop using bundler (ie 'bundle exec rubocop')"
},
"ruby.rubocop.suppressRubocopWarnings": {
"docker-ruby.rubocop.suppressRubocopWarnings": {
"type": "boolean",
"default": false,
"description": "Suppress warnings from rubocop and attempt to run regardless. (Useful if you share a rubocop.yml file and run into unrecognized cop errors you know are okay.)"
},
"docker-ruby.rubocop.useDocker": {
"type": "boolean",
"default": false,
"description": "Whether to use docker or not. If this option is false, settig a value to dockerContainer will be useless."
},
"docker-ruby.rubocop.dockerContainer": {
"type": "string",
"default": "",
"description": "Name of the docker container to use the interpretr from"
},
"docker-ruby.rubocop.disableEmptyFileCop": {
"type": "boolean",
"default": false,
"description": "should Lint/EmptyFile Cop should run?"
}
}
}
Expand Down