Coder Social home page Coder Social logo

rubocop-rake's Introduction

RuboCop Logo


Ruby Style Guide Gem Version Actions Status Test Coverage Maintainability Discord

Role models are important.
-- Officer Alex J. Murphy / RoboCop

RuboCop is a Ruby static code analyzer (a.k.a. linter) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. Apart from reporting the problems discovered in your code, RuboCop can also automatically fix many of them for you.

RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options.


Patreon OpenCollective OpenCollective Tidelift

Working on RuboCop is often fun, but it also requires a great deal of time and energy.

Please consider financially supporting its ongoing development.

Installation

RuboCop's installation is pretty standard:

$ gem install rubocop

If you'd rather install RuboCop using bundler, add a line for it in your Gemfile (but set the require option to false, as it is a standalone tool):

gem 'rubocop', require: false

RuboCop is stable between minor versions, both in terms of API and cop configuration. We aim to ease the maintenance of RuboCop extensions and the upgrades between RuboCop releases. All big changes are reserved for major releases. To prevent an unwanted RuboCop update you might want to use a conservative version lock in your Gemfile:

gem 'rubocop', '~> 1.65', require: false

See our versioning policy for further details.

Quickstart

Just type rubocop in a Ruby project's folder and watch the magic happen.

$ cd my/cool/ruby/project
$ rubocop

You can also use this magic in your favorite editor with RuboCop's built-in LSP server.

Documentation

You can read a lot more about RuboCop in its official docs.

Compatibility

RuboCop officially supports the following runtime Ruby implementations:

  • MRI 2.7+
  • JRuby 9.4+

Targets Ruby 2.0+ code analysis.

See the compatibility documentation for further details.

Readme Badge

If you use RuboCop in your project, you can include one of these badges in your readme to let people know that your code is written following the community Ruby Style Guide.

Ruby Style Guide

Ruby Style Guide

Here are the Markdown snippets for the two badges:

[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)

[![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)

Team

Here's a list of RuboCop's core developers:

See the team page for more details.

Logo

RuboCop's logo was created by Dimiter Petrov. You can find the logo in various formats here.

The logo is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Contributors

Here's a list of all the people who have contributed to the development of RuboCop.

I'm extremely grateful to each and every one of them!

If you'd like to contribute to RuboCop, please take the time to go through our short contribution guidelines.

Converting more of the Ruby Style Guide into RuboCop cops is our top priority right now. Writing a new cop is a great way to dive into RuboCop!

Of course, bug reports and suggestions for improvements are always welcome. GitHub pull requests are even better! :-)

Funding

While RuboCop is free software and will always be, the project would benefit immensely from some funding. Raising a monthly budget of a couple of thousand dollars would make it possible to pay people to work on certain complex features, fund other development related stuff (e.g. hardware, conference trips) and so on. Raising a monthly budget of over $5000 would open the possibility of someone working full-time on the project which would speed up the pace of development significantly.

We welcome both individual and corporate sponsors! We also offer a wide array of funding channels to account for your preferences (although currently Open Collective is our preferred funding platform).

If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company to become a RuboCop sponsor.

You can support the development of RuboCop via GitHub Sponsors, Patreon, PayPal, Open Collective and Tidelift .

Note: If doing a sponsorship in the form of donation is problematic for your company from an accounting standpoint, we'd recommend the use of Tidelift, where you can get a support-like subscription instead.

Open Collective for Individuals

Support us with a monthly donation and help us continue our activities. [Become a backer]

Open Collective for Organizations

Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

Changelog

RuboCop's changelog is available here.

Copyright

Copyright (c) 2012-2024 Bozhidar Batsov. See LICENSE.txt for further details.

rubocop-rake's People

Contributors

bquorning avatar dvandersluis avatar jaruuu avatar koic avatar m-nakamura145 avatar pocke avatar pvdb avatar tejasbubane 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rubocop-rake's Issues

Bug: require 'rubocop/rake_task' after 'rubocop-rake'

Hello! I found a simple bug when you can not require and build your custom rubocop-rake task by using RuboCop::RakeTask with rubocop-rake together :)

If you require all dependencies in the following order:

require 'rubocop'
require 'rubocop/rake_task'
require  'rubocop-rake'

OK? Ok :)

But if you want to require your global dependencies before any internal dependency:

require 'rubocop'
require 'rubocop-rake'
require 'rubocop/rake_task'

You will fail with:

➜ bundle exec rake rubocop
rake aborted!
NameError: uninitialized constant RuboCop::Rake::TaskLib

Real example:

  • correct behavior:
require 'rubocop'
require 'rubocop/rake_task' # rubocop/rake_task is a first
require 'rubocop-rake' # rubocop-rake is a second

RuboCop::RakeTask.new(:rubocop) do |t|
  config_path = File.expand_path(File.join('.rubocop.yml'), __dir__)
  t.options = ['--config', config_path]
  t.requires << 'rubocop-rake'
end
  • (bug) incorrect behavior:
require 'rubocop'
require 'rubocop-rake' # rubocop-rake is a first
require 'rubocop/rake_task' # rubocop/rake is a second

RuboCop::RakeTask.new(:rubocop) do |t|
  config_path = File.expand_path(File.join('.rubocop.yml'), __dir__)
  t.options = ['--config', config_path]
  t.requires << 'rubocop-rake'
end

The problem is here:

(gem rubocop)

# rubocop/lib/rubocop/rake_task.rb

# frozen_string_literal: true

require 'rake'
require 'rake/tasklib'

module RuboCop
  # Provides a custom rake task.
  #
  # require 'rubocop/rake_task'
  # RuboCop::RakeTask.new
  class RakeTask < Rake::TaskLib # <<<<< HERE
...

and here:

(gem rubocop-rake)

# rubocop-rake/blob/master/lib/rubocop/rake.rb

# frozen_string_literal: true

require "rubocop/rake/version"

module RuboCop
  # :nodoc:
  module Rake # <<< HERE
...

Real rubocop uses internal namespace. Your RuboCop::Rake hides the real Rake namespace. And its a problem :)

I think this is a problem of the real rubocop. And The real rubocop can resolve this issue via global constant namespace declaration/resolution (::Rake::TaskLib). WDYT?

Enhancement: Rake/DuplicateTask to work across multiple files

What would it take for the Rake/DuplicateTask cop to work across all rake files?

The use case I'm facing is the following:

  • task_a.rake defines :task_a
  • task_b.rake defines :task_a

This of course will theoretically run all occurrences of :task_a.

However in my case the two definitions of :task_a have different parameters. The second definition overrides the parameters defined in the first place and finally the first fails because it can't get a proper value for its parameters, which prevents Rake to proceed with the second task and thus there's no obvious hint of the problem.

Ending up in such situation is obviously not intended, and that's why it would be most useful to detect such issues.
use_case_rake_duplicate_task_across_files.zip

How to avoid triggering Rake/Desc when adding additional dependencies to an existing task?

I have the following:

# This defines the task 'build'
require "bundler/gem_tasks"

# [...]

# This defines the task 'manifest:check'
Rake::Manifest::Task.new do |t|
  t.patterns = ["{lib}/**/*", "LICENSE"]
end

# I want the task 'manifest:check' to be run before the task 'build'
task build: "manifest:check"

The build task already has a description, but Rake/Desc still reports an offense:

Rakefile:30:1: C: Rake/Desc: Describe the task with desc method.
task build: "manifest:check"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

How should I proceed to resolve this?

Compiler version

It either fails to verify on " Error! Unable to generate Contract ByteCode and ABI (Expected library(ies) but one or more was not provided)"

ParserError: Expected pragma, import directive or contract/interface/library/struct/enum/constant/function definition --> myc:1:1: | 1 PatientResult { ^----^ Compilation failed.

Contract address: 0xdd9fd6b6f8f7ea932997992bbe67eabb3e316f3c ( Last Winner )

New cop: duplicated task definition

# Rakefile

task :foo do
  p 'foo'
end

task :foo do
  p 'foo2'
end

rake foo prints "foo" and "foo2".
I think it is not expected sometimes.
And we can merge the task definitions to one.

So we should have a cop to detect the code.

New cop: system vs sh

In Rake task, I prefer sh to system to execute external commands.
Because sh raises an error when the command exits with non-zero. It is safer.

task :foo do
  system 'false' # It does not raise any errors
  sh 'false' # It raises an error.
end

Note: I think system in not void context is ok. So the cop should not add any offense for the following code.

task :foo do
  # It does not raise, but handled.
  if system 'cmd'
    # ...
  end
end

Style for task dependency syntax

  1. Move the Rails/RakeEnvironment cop to rubocop-rake as the Rake/Rails/RakeEnvironment cop.

  2. The cop accepts two valid styles. I think one should be the preferred choice.

a)

desc 'delete non-unique banners'
task 'delete_non_unique_banners' => :environment do
  # ...
end

or

b)

desc 'delete non-unique banners'
task delete_non_unique_banners: :environment do
  # ...
end

New cop: Add an offense for `def` in task definition

desc 'foo'
task :foo do
  def helper_method
  end
end

task does not create any namespace. It means the helper_method will define as a top-level method.
It is unexpected behavior in many cases, so a cop should mark the code as offensive.

Rake/Desc false positive

desc 'Method #3: Use ARGV to add two numbers and log the result'
task :add do
  ARGV.each { |a| task a.to_sym do ; end }
  puts ARGV[1].to_i + ARGV[2].to_i
end

This code (from here) gives an offense on the line starting ARGV... even though the task description is included above. Similar to #36 I guess.

False positive on `Rake/Desc` cop

Actual behavior

task lint: %i[rubocop]

terminal:

ydakuka@yauhenid:~/Work/project$ bin/rails_docker rubocop Rakefile 
Inspecting 1 file
.

1 file inspected, no offenses detected

Rubocop

ydakuka@yauhenid:~/Work/main_app$ bin/rails_docker rubocop -V
1.57.1 (using Parser 3.2.2.4, rubocop-ast 1.29.0, running on ruby 2.7.8) [x86_64-linux]
  - rubocop-capybara 2.19.0
  - rubocop-factory_bot 2.24.0
  - rubocop-performance 1.19.1
  - rubocop-rails 2.21.1
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.24.1
  - rubocop-thread_safety 0.5.1

Errors not detected in rakelib tasks

Background

rakelib

The rakelib directory is the default location for Rake apps that are split across multiple files.

The location/name of the rakelib directory can be customized with:

spec = Gem::Specification.find_by_name "my_gem"
rakelib = "#{spec.gem_dir}/lib/my_gem/rakelib"
Rake.add_rakelib(rakelib)

* Note that customization via add_rakelib is not fully documented in the RDocs related to rakelib. rakelib does not have to be at the root alongside the main Rakefile.

Inside my rakelib I have a bunch of namespaced folders and *.rake files.

shared rake task

Gems with shared rake tasks generally place them in lib/my_gem/tasks.rake or similar, and instruct users to integrate with their Rakefile as require "my_gem/tasks.rake".

Expected

Any file in any subdirectory of RuboCop's working directory that matches Rakefile or *.rake, or any of the other standard Rake file names (rakefile.rb, etc) should be processed by this RuboCop extension.

Bug

  1. Within my_gem RuboCop violations in my rakelib are not detected (see above "rakelib").
  2. Within my_gem RuboCop violations in my shared rake task are not detected (see above "shared rake task").

The only issues that are detected in my_gem are in the root Rakefile.

`MethodDefinitionInTask` false positive for `Data` class

Althrough MethodDefinitionInTask cop does a good job ignoring method definitions in classes/modules, it does not detect Data methods:

# some rake task

Data.define(:data) do
  def some_helper_method # Rake/MethodDefinitionInTask complains here
    data.do_something
  end
end

Invitation to host this project under RuboCop HQ :-)

I guess the title says it all. :-) I'd love to host most RuboCop extensions under RuboCop HQ and you've got an invitation to move the project there if you'd like to. I think this help users discover extensions and also helps with them being developed in a uniform manner.

Let me know what do you think about this. You're already a member of the org, so moving the project there should require no intervention from me.

Rake/MethodDefinitionInTask is 66.6% incorrect

The good code is bad, and the bad code is good.

Methods should be defined inside tasks (only)

(but not namespaces), as it is the only way they will not be globally scoped, and thereby silently conflict with all other same-named globally scoped methods.

Obviously it is also fine to define methods in classes or modules... that's outside the scope of this issue.

definition location scope rubocop-rake should consider rubocop-rake currently considers
top-level global bad πŸ›‘ good βœ…
namespace block global bad πŸ›‘ bad πŸ›‘
task block task good βœ… bad πŸ›‘

"Good Code" example for task:

namespace :foo_namespace do
  desc 'foo task'
  task :foo do
    def greet
      puts 'Hello from foo.rake'
    end
 
    puts 'In foo task'
    greet
  end
end

"Bad Code" example for namespace:

namespace :foo_namespace do
  desc 'foo task'
  task :foo do
    puts 'In foo task'
    greet
  end
 
  def greet
    puts 'Hello from foo.rake'
  end
end

"Bad Code" example for top-level:

desc 'foo task'
task :foo do
  puts 'In foo task'
  greet
end
 
def greet
  puts 'Hello from foo.rake'
end

reference: https://www.albertoalmagro.com/en/ruby-methods-defined-in-rake-tasks/

Rake/Desc failure

Hi there. Thanks for putting together this project. I wanted to let you know about an issue with the Rake/Desc cop.

An error occurred while Rake/Desc cop was inspecting /Users/tsmith/dev/work/chef-dk/Rakefile:36:47.
undefined method `send_type?' for :name:Symbol
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-rake-0.5.0/lib/rubocop/cop/rake/desc.rb:50:in `task_with_desc?'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-rake-0.5.0/lib/rubocop/cop/rake/desc.rb:36:in `on_task'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-rake-0.5.0/lib/rubocop/cop/rake/helper/on_task.rb:17:in `on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:57:in `block (2 levels) in trigger_responding_cops'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:128:in `with_cop_error_handling'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:56:in `block in trigger_responding_cops'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:55:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:55:in `trigger_responding_cops'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:32:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:107:in `block in on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `each_with_index'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_dstr'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_dstr'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:107:in `block in on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `each_with_index'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:104:in `on_send'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:141:in `on_if'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:169:in `block in on_case'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:168:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:168:in `on_case'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:169:in `block in on_case'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:168:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:168:in `on_case'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_kwbegin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_kwbegin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:164:in `on_block'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `block in on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:50:in `on_begin'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:33:in `block (2 levels) in <class:Commissioner>'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/traversal.rb:13:in `walk'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/commissioner.rb:44:in `investigate'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/team.rb:119:in `investigate'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/team.rb:107:in `offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/team.rb:44:in `inspect_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:283:in `inspect_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:231:in `block in do_inspection_loop'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:263:in `block in iterate_until_no_changes'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:256:in `loop'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:256:in `iterate_until_no_changes'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:227:in `do_inspection_loop'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:124:in `block in file_offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:142:in `file_offense_cache'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:122:in `file_offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:110:in `process_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:87:in `block in each_inspected_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:86:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:86:in `reduce'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:86:in `each_inspected_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:73:in `inspect_files'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/runner.rb:39:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cli.rb:210:in `execute_runner'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cli.rb:80:in `execute_runners'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cli.rb:51:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/exe/rubocop:13:in `block in <top (required)>'
/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.75.1/exe/rubocop:12:in `<top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/chefstyle-0.14.0/bin/chefstyle:13:in `load'
/usr/local/lib/ruby/gems/2.6.0/gems/chefstyle-0.14.0/bin/chefstyle:13:in `<top (required)>'
/usr/local/lib/ruby/gems/2.6.0/bin/chefstyle:23:in `load'
/usr/local/lib/ruby/gems/2.6.0/bin/chefstyle:23:in `<main>'```

Here's the content of the Rakefile:

```ruby
#
# Copyright:: Copyright (c) 2016-2018 Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

begin
  require_relative "tasks/dependencies"
  require_relative "tasks/announce"
rescue LoadError
  puts "Additional rake tasks not found. If you require these rake tasks run Rake from the git repo not the installation files!"
end

namespace :style do
  begin
    require "rubocop/rake_task"

    desc "Run Cookbook Ruby style checks"
    RuboCop::RakeTask.new(:cookstyle) do |t|
      t.requires = ["cookstyle"]
      t.patterns = ["lib/chef-dk/skeletons/code_generator"]
      t.options = ["--display-cop-names"]
    end
  rescue LoadError => e
    puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"]
  end

  begin
    require "rubocop/rake_task"

    ignore_dirs = Regexp.union(%w{
      lib/chef-dk/skeletons/code_generator
      spec/unit/fixtures/chef-runner-cookbooks
      spec/unit/fixtures/cookbook_cache
      spec/unit/fixtures/example_cookbook
      spec/unit/fixtures/example_cookbook_metadata_json_only
      spec/unit/fixtures/example_cookbook_no_metadata
      spec/unit/fixtures/local_path_cookbooks
    })

    desc "Run Cookstyle style checks"
    RuboCop::RakeTask.new(:chefstyle) do |t|
      t.requires = ["chefstyle"]
      t.patterns = `rubocop --list-target-files`.split("\n").reject { |f| f =~ ignore_dirs }
      t.options = ["--display-cop-names"]
    end
  rescue LoadError => e
    puts ">>> Gem load error: #{e}, omitting #{task.name}" unless ENV["CI"]
  end
end

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.