Tab cutter

We would like to use Rubocop to validate our Ruby and the correctness of the underlying code.

Appart from this rule: we back out using tabs so that someone decides how they want them to appear (display them as 2 or 4 spaces)

The problem is that rubocop seems to be designed to discard tabs for AT ALL indents.

How can we redefine all the thesis rules to be helpers in space?

EDIT: I am thinking of overriding this module https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/source_parser.rb to replace all tabs from my files with 2 spaces to create an illusion for the gem .. .

+4
source share
3 answers

I overcame this module https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/source_parser.rb to replace all tabs from my files with 2 spaces to create an illusion for the gem ...

0
source

Add to your .rubocop.yml:

Style/Tab:
  Enabled: false

to disable the tab rule.

You can write your own custom cop. to check the correct indentation.

+9
source

, . 0.32.1:

--- processed_source.rb.orig    2015-07-28 05:53:52.199418557 +0100
+++ processed_source.rb 2015-07-28 05:54:04.750420458 +0100
@@ -13,7 +13,7 @@
                 :parser_error, :raw_source

     def self.from_file(path)
-      file = File.read(path)
+      file = File.read(path).gsub(/^(\t+)/) {|m| '  ' * m.size }
       new(file, path)
     rescue
       abort("#{Rainbow('rubocop: No such file or directory').red} -- #{path}")

. Bwahahaha.

+2

Source: https://habr.com/ru/post/1543283/


All Articles