Skip to content

Commit

Permalink
Merge pull request #46 from yujinakayama/rubocop-1.0
Browse files Browse the repository at this point in the history
Support RuboCop 1.0
  • Loading branch information
yujinakayama authored Oct 27, 2020
2 parents 5ccbb2a + 61d0394 commit 5a1cbc0
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 22 deletions.
19 changes: 13 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
inherit_from: .rubocop_todo.yml

Layout/IndentArray:
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Layout/LineLength:
Max: 100

Lint/MissingSuper:
Exclude:
- spec/support/silence_output.rb

Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'

Metrics/LineLength:
Max: 100

Metrics/MethodLength:
Max: 15

Naming/HeredocDelimiterNaming:
Enabled: false

Naming/RescuedExceptionsVariableName:
PreferredName: error

Style/EmptyMethod:
EnforcedStyle: expanded

Style/MethodMissing:
Style/FrozenStringLiteralComment:
Exclude:
- spec/support/silence_output.rb
- lib/guard/rubocop/templates/Guardfile

Style/RegexpLiteral:
Exclude:
Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: ruby
rvm:
- 2.2.9
- 2.3.6
- 2.4.3
- 2.5.0
- jruby-9.1.15.0
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
Expand Down
2 changes: 2 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![Gem Version](https://badge.fury.io/rb/guard-rubocop.svg)](http://badge.fury.io/rb/guard-rubocop)
[![Dependency Status](https://gemnasium.com/yujinakayama/guard-rubocop.svg)](https://gemnasium.com/yujinakayama/guard-rubocop)
[![Build Status](https://travis-ci.org/yujinakayama/guard-rubocop.svg?branch=master&style=flat)](https://travis-ci.org/yujinakayama/guard-rubocop)
[![Coverage Status](https://coveralls.io/repos/yujinakayama/guard-rubocop/badge.svg?branch=master&service=github)](https://coveralls.io/github/yujinakayama/guard-rubocop?branch=master)
[![Code Climate](https://codeclimate.com/github/yujinakayama/guard-rubocop/badges/gpa.svg)](https://codeclimate.com/github/yujinakayama/guard-rubocop)
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
Expand Down
11 changes: 7 additions & 4 deletions guard-rubocop.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

require 'guard/rubocop/version'
Expand All @@ -14,19 +16,20 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/yujinakayama/guard-rubocop'
spec.license = 'MIT'

spec.required_ruby_version = '>= 2.4'

spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
spec.test_files = spec.files.grep(/^spec\//)
spec.require_paths = ['lib']

spec.add_runtime_dependency 'guard', '~> 2.0'
spec.add_runtime_dependency 'rubocop', '~> 0.20'
spec.add_runtime_dependency 'rubocop', '< 2.0'

spec.add_development_dependency 'bundler', '~> 1.3'
spec.add_development_dependency 'guard-rspec', '>= 4.2.3', '< 5.0'
spec.add_development_dependency 'launchy', '~> 2.4'
spec.add_development_dependency 'rake', '~> 12.0'
spec.add_development_dependency 'rake', '>= 12.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'ruby_gntp', '~> 0.3'
spec.add_development_dependency 'simplecov', '~> 0.7'
end
5 changes: 4 additions & 1 deletion lib/guard/rubocop.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'guard'
require 'guard/plugin'

Expand All @@ -14,7 +16,7 @@ def initialize(options = {})

@options = {
all_on_start: true,
keep_failed: true,
keep_failed: true,
notification: :failed,
cli: nil,
hide_stdout: false
Expand Down Expand Up @@ -74,6 +76,7 @@ def clean_paths(paths)
paths.uniq!
paths.reject! do |path|
next true unless File.exist?(path)

included_in_other_path?(path, paths)
end
paths
Expand Down
16 changes: 9 additions & 7 deletions lib/guard/rubocop/runner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'

module Guard
Expand Down Expand Up @@ -113,13 +115,12 @@ def failed_paths
end

def pluralize(number, thing, options = {})
text = ''

if number.zero? && options[:no_for_zero]
text = 'no'
else
text << number.to_s
end
text =
if number.zero? && options[:no_for_zero]
+'no'
else
number.to_s
end

text << " #{thing}"
text << 's' unless number == 1
Expand All @@ -130,6 +131,7 @@ def pluralize(number, thing, options = {})
def open_launchy_if_needed
return unless (output_path = @options[:launchy])
return unless File.exist?(output_path)

require 'launchy'
::Launchy.open(output_path)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/guard/rubocop/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# A workaround for declaring `class RuboCop`
# before `class RuboCop < Guard` in rubocop.rb
module GuardRuboCopVersion
Expand Down
2 changes: 2 additions & 0 deletions spec/guard/rubocop/runner_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'launchy'

RSpec.describe Guard::RuboCop::Runner do
Expand Down
2 changes: 2 additions & 0 deletions spec/guard/rubocop_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe Guard::RuboCop, :silence_output do
subject(:guard) { Guard::RuboCop.new(options) }
let(:options) { {} }
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
Expand All @@ -20,7 +22,7 @@
Kernel.srand config.seed
end

Dir[File.join(File.dirname(__FILE__), 'support', '*')].each do |path|
Dir[File.join(File.dirname(__FILE__), 'support', '*')].sort.each do |path|
require path
end

Expand Down
6 changes: 6 additions & 0 deletions spec/support/silence_output.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.shared_context 'silence output', :silence_output do
null_object = BasicObject.new

Expand All @@ -7,6 +9,10 @@ def respond_to?(*)
true
end

def respond_to_missing?(*)
true
end

def method_missing(*)
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/support/simplecov.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'simplecov'

if ENV['CI']
Expand Down

0 comments on commit 5a1cbc0

Please sign in to comment.