GithubHelp home page GithubHelp logo

ruumba's Introduction

Ruumba

Build Status

.erb or .rb, you're coming with me.

— RuboCop

About

Ruumba is RuboCop's sidekick, allowing you to lint your .erb Rubies as well as your regular-type ones.

Dependencies

  • Ruby 2.4+

Installation

λ gem install ruumba

Usage

Command line:

λ ruumba directory_of_erb_files/

Rake task:

require 'ruumba/rake_task'

Ruumba::RakeTask.new(:ruumba) do |t|
  t.dir = %w(lib/views)

  # You can specify CLI options too:
  t.options = { arguments: %w[-c .ruumba.yml] }
end

Then:

λ bundle exec rake ruumba

Fix Paths and Non-Applicable Cops

By default, RuboCop only scans .rb files and so does Ruumba. If you want shown paths to reflect original paths, you can add create a .ruumba.yml config file with the following contents:

AllCops:
  Include:
    - '**/*.erb'

You can then disable the .rb extension auto-append and use your config file:

λ ruumba -D -e app/views -c .ruumba.yml

Since Ruumba rewrites new files from .erb files contents, some formatting cops cannot apply. You can disable them in your Ruumba config file:

Style/FrozenStringLiteralComment:
  Enabled: false
Layout/HashAlignment:
  Enabled: false
Layout/ParameterAlignment:
  Enabled: false
Layout/IndentationWidth:
  Enabled: false
Layout/TrailingEmptyLines:
  Enabled: false

You can use ruumba -a or ruumba -D to look for other cops if this list is missing some.

You might want to include your existing RuboCop config file by appending this in front of your Ruumba config:

inherit_from: .rubocop.yml

Editor Integrations

Contributing

  1. Branch (git checkout -b fancy-new-feature)
  2. Commit (git commit -m "Fanciness!")
  3. Test (bundle exec rake spec)
  4. Lint (bundle exec rake rubocop)
  5. Push (git push origin fancy-new-feature)
  6. Ye Olde Pulle Requeste

ruumba's People

Contributors

aclemons avatar derjanb avatar ericqweinstein avatar hlfh avatar take-cheeze avatar tleish avatar vzamanillo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruumba's Issues

Infinite Nested tmp/erb files

When using a tmp folder located within a project being analyzed by ruumba (e.g. <project root>/tmp/ruumba), it duplicates files with each run. This not only creates extra files in the project, but exponentially adds more for rubocop to analyze.

For example:

New Project

└── template.html.erb

First Ruumba Run:

├── template.html.erb
└── tmp
    └── ruumba
        └── template.html.erb

Second Ruumba Run:

├── template.html.erb
└── tmp
    └── ruumba
        ├── template.html.erb
        └── tmp
            └── ruumba
                └── template.html.erb

Third Ruumba Run:

├── template.html.erb
└── tmp
    └── ruumba
        ├── template.html.erb
        └── tmp
            └── ruumba
                ├── template.html.erb
                └── tmp
                    └── ruumba
                        └── template.html.erb

Expected Behavior

Exclude all files in tmp folder for copying template files

Add --exclude-limit option.

An --exclude-limit option like Rubocop has would be very useful.

I prefer to have a complete list of infractions generated by --auto-gen-config and not have my tools decide when rules should be turned off, so you never get a chance to ratchet them down.

Ruumba has such a limit like Rubocop does, but Rubocop lets you use --exclude-limit. So it's incredibly difficult to generate such a list.

Layout/TrailingWhitespace on every single line

test.html.erb

<div>
  <p>Test ERB file</p>
</div>

Ruumba output:

% ruumba -v                                                                                                                                                                                                                
ruumba 0.1.16

% ruumba test.html.erb                                                                                                                                                                                                     
Inspecting 1 file
C

Offenses:

test.html.erb:1:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.
test.html.erb:1:2: C: Layout/TrailingEmptyLines: 2 trailing blank lines detected.
test.html.erb:2:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.
test.html.erb:3:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Emacs formatter results in raw (unreadable) path names in output.

I am attempting to integrate ruumba into OverCommit, so we can automatically run ruumba on our code as a pre-commit hook, with nice-looking output.

I have discovered that using the emacs formatter prevents the output filenames being corrected / displayed correctly (as works fine for other formatters). Output below.

Is there a way to fix this our side?

I am on ruumba (0.1.5) and rubocop (0.58.2) and my ruumba.yml (if relevant) was shared here.

Output from simple formatter (notice pretty file names):

$ bundle exec ruumba --disable-ruby-ext --config .ruumba.yml --format=simple app/views
== app/views/users/download_app.html.erb ==
C: 10: 79: Layout/MultilineArrayBraceLayout: Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.

431 files inspected, 1 offense detected

Output from emacs formatter (notice ugly file name prefixes):

$ bundle exec ruumba --disable-ruby-ext --config .ruumba.yml --format=emacs app/views
/private/var/folders/6x/f21_1m6k4nb652lp1d3_5ldw0000kn/T/d23684922-5977-tt7h84/app/views/users/download_app.html.erb:10:79: C: Layout/MultilineArrayBraceLayout: Closing array brace must be on the line after the last array element when opening brace is on a separate line from the first array element.

JUNIT reporter does not create output file

If I specify --out report.xml it does not create the file, without the parameter I can get the correct junit report.

Version: 0.93.1 (using Parser 3.1.0.0, rubocop-ast 1.15.1, running on ruby 2.7.2 x86_64-linux)

Ruumba not finding any files.

For some reason ruumba is not finding any files to lint. I've tried running the basic ruumba commands without a .ruumba.yml file and with a default .ruumba.yml config but both yield 0 files inspected, no offenses detected

Commands run are bin/ruumba ./ bundle exec ruumba ./ bundle exec ruumba app/views ruumba -D -e app/views -c .ruumba.yml

Even running on a specific file is still returning 0 files inspected.

Can anyone provide some insight on why this could be happening?

Contents of .ruumba.yml is:

inherit_from: .rubocop.yml

AllCops:
  Include:
    - '**/*.erb'

# The following cops are not applicable to ERB files

Style/CommentedKeyword:
  Enabled: false

Style/FrozenStringLiteralComment:
  Enabled: false

# Arguably all 'Layout' cops are not applicable

Layout/AlignHash:
  Enabled: false

Layout/AlignParameters:
  Enabled: false

Layout/BlockAlignment:
  Enabled: false

Layout/CaseIndentation:
  Enabled: false

Layout/ClosingParenthesisIndentation:
  Enabled: false

Layout/CommentIndentation:
  Enabled: false

Layout/ConditionPosition:
  Enabled: false

Layout/EndAlignment:
  Enabled: false

Layout/ElseAlignment:
  Enabled: false

Layout/EmptyLines:
  Enabled: false

Layout/EmptyLinesAroundBlockBody:
  Enabled: false

Layout/ExtraSpacing:
  Enabled: false

Layout/IndentFirstArgument:
  Enabled: false

Layout/IndentFirstArrayElement:
  Enabled: false

Layout/IndentationConsistency:
  Enabled: false

Layout/IndentationWidth:
  Enabled: false

Layout/IndentFirstHashElement:
  Enabled: false

Layout/InitialIndentation:
  Enabled: false

Layout/LeadingBlankLines:
  Enabled: false

Layout/LeadingCommentSpace:
  Enabled: false

Layout/MultilineMethodCallBraceLayout:
  Enabled: false

Layout/MultilineMethodCallIndentation:
  Enabled: false

Layout/SpaceAfterColon:
  Enabled: false

Layout/SpaceAfterComma:
  Enabled: false

Layout/SpaceAroundOperators:
  Enabled: false

Layout/SpaceBeforeBlockBraces:
  Enabled: false

Layout/SpaceBeforeComma:
  Enabled: false

Layout/SpaceBeforeComment:
  Enabled: false

Layout/SpaceBeforeFirstArg:
  Enabled: false

Layout/SpaceBeforeSemicolon:
  Enabled: false

Layout/SpaceInsideArrayLiteralBrackets:
  Enabled: false

Layout/SpaceInsideBlockBraces:
  Enabled: false

Layout/SpaceInsideHashLiteralBraces:
  Enabled: false

Layout/SpaceInsideParens:
  Enabled: false

Layout/SpaceInsideStringInterpolation:
  Enabled: false

Layout/TrailingBlankLines:
  Enabled: false

Layout/TrailingWhitespace:
  Enabled: false

# Incorrectly flagged by Ruumba
# Typically the false positives relate to important HTML differences which aren't
# inside ERB tags and so aren't detected correctly by Ruumba.
# TODO: Monitor these, and re-enable permanently once Ruumba flags correctly.

Lint/Void:
  Enabled: false

Lint/EmptyWhen:
  Enabled: false

Style/EmptyElse:
  Enabled: false

Style/IdenticalConditionalBranches:
  Enabled: false

Style/IfInsideElse:
  Enabled: false

Style/IfUnlessModifier:
  Enabled: false

Style/Next:
  Enabled: false

Style/UnneededCondition:
  Enabled: false

# TODO: Enable cops below and resolve violations.
# Note: The `--auto-gen-config` flag is glitchy with `ruumba`.
# To re-generate this list;
# - delete all rules below this comment and save.
# - run `bin/ruumba`
# - Copy full output (many errors + warnings!)
# - Use text manipulation to extract occurrences of `: C: XXXX/YYYY` and `: W: XXXX/YYYY`
# - De-duplicate and sort the matching cop names
# - Paste below and manipulate to be `Enabled: false` in each case.

Metrics/BlockLength:
  Enabled: false

Metrics/BlockNesting:
  Enabled: false

Metrics/LineLength:
  Enabled: false

Style/BlockDelimiters:
  Enabled: false

Style/BracesAroundHashParameters:
  Enabled: false

Style/MultilineIfModifier:
  Enabled: false

Style/NestedParenthesizedCalls:
  Enabled: false

Style/NestedTernaryOperator:
  Enabled: false

Style/Semicolon:
  Enabled: false

Style/StringLiterals:
  Enabled: false

Style/SymbolProc:
  Enabled: false

Style/TernaryParentheses:
  Enabled: false

Style/ZeroLengthPredicate:
  Enabled: false

Add autofix option

Rubocop has autofix option -a. It is very useful for legacy projects.

Can you add it to ruumba?

Allow omitting directory.

It would be nice to be able to omit the directory arguments, like you can with Rubocop, where it effectively just uses ".".

Invalid byte sequence when running on CI

When running Ruumba on our CI (continuous integration) system, it's failing with the backtrace below (triggered on this line).

Any idea what I can do to fix this? It doesn't appear specifically related to this gem, but I've tried workarounds mentioned elsewhere (setting LC_ALL and LANG env vars).

We experienced similar problems (again, on CI only) with Brakeman - presidentbeef/brakeman#102. In that case, setting LC_ALL as suggested fixed the problem. No luck with Ruumba.

Is it possible that this gem could rescue the exception, and identify any incorrectly formatted/encoded files in some way, rather than crashing?

bash: warning: setlocale: LC_ALL: cannot change locale (en_GB.UTF-8)
/pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:58:in `gsub': invalid byte sequence in US-ASCII (ArgumentError)
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:58:in `parse_file'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:37:in `extract'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:105:in `block (2 levels) in copy_erb_files'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:104:in `open'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:104:in `block in copy_erb_files'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:100:in `each'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:100:in `copy_erb_files'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/lib/ruumba/analyzer.rb:29:in `run'
	from /pipeline/cache/bundle-install/ruby/2.4.0/gems/ruumba-0.1.3/bin/ruumba:70:in `<top (required)>'
	from /pipeline/cache/bundle-install/ruby/2.4.0/bin/ruumba:25:in `load'
	from /pipeline/cache/bundle-install/ruby/2.4.0/bin/ruumba:25:in `<main>'

The script used to execute ruumba (bin/ruumba) is:

#!/usr/bin/env bash

bundle exec ruumba -D -e app/views -c .ruumba.yml

Running bin/ruumba on my local system runs smoothly (reporting "no offenses detected").

An error occurred with Style/IfWithSemicolon

If I disable this specific cop, it runs correctly.

An error occurred while Style/IfWithSemicolon cop was inspecting /tmp/d20231211-21400-1u2korb/site-cookbooks/swf-base/templates/default/keepalived.erb:21:11.
An error occurred while Style/IfWithSemicolon cop was inspecting /tmp/d20231211-21400-1u2korb/site-cookbooks/swf-base/templates/default/keepalived.erb:24:14.

2 errors occurred:
An error occurred while Style/IfWithSemicolon cop was inspecting /tmp/d20231211-21400-1u2korb/site-cookbooks/swf-base/templates/default/keepalived.erb:21:11.
An error occurred while Style/IfWithSemicolon cop was inspecting /tmp/d20231211-21400-1u2korb/site-cookbooks/swf-base/templates/default/keepalived.erb:24:14.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues

Mention the following information in the issue report:
0.93.1 (using Parser 3.1.0.0, rubocop-ast 1.15.1, running on ruby 2.7.2 x86_64-linux)

How best to use ruumba with rubocop on a Rails project?

We have a .rubocop.yml file, which inherits from a .rubocop_todo.yml file generated with the --auto-gen-config option.

I've just tried running ruumba app/views --auto-gen-config and it's overwritten my .rubocop_todo.yml file.

What's more it hasn't made ruumba app/views run cleanly, I still get lots of warnings from it.

There's some notes in your README about using a .ruumba.yml and inheriting from .rubocop.yml? I've tried that but it's still not running cleanly.

How do you recommend we lay out our configuration files for rubocop and ruumba, and which command or commands should we run to run them?

I think this would be a useful section to add to your README file somewhere. Thanks!

Inconsistent indentation detected. [[Correctable] Layout/IndentationConsistency]

As describe in #54, i meet same issue with Layout/TrailingWhitespace, i have to disable it in config.

But, after that, there still exists another issue, as describe on issue title.

Following is my source code.

https://github.com/zw963/marketbet_crawler/blob/master/views/institutions/_institution.erb

I open this file use web-mode, i never see any indent issue, but get many warn message like this under % of <%==

image

I use ruby 3.0.2
rubocop 1.19.1

Allow accepting files instead of just directories.

I should be able to just check one file, instead of having to specify a full directory. Rubocop handles this fine.

» bundle exec ruumba app/views/home/index.html.erb
Inspecting 0 files


0 files inspected, no offenses detected

Use default configuration file .ruumba.yml.

If you don't specify a config file on the command line, Rubocop will use the default of .rubocop.yml if it exists.

It would be nice if Ruumba would look at .ruumba.yml by default if it exists.

Add --only option.

The --only option is very useful, especially in concert with the (hopefully) incoming --auto-correct option, to just target one type of problem at a time.

For example, using this, I could put tightly related changes into a single commit, and less related ones into other commits.

Lint/Void cop triggered by <%=

Since rubocop no longer has the context of the code, the Lint/Void cop will be tiggered by code such as:

<h1><%= thing(param) + " String - " + @foo.baz %></h1>

Operator + used in a void context.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.