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

Issue #504: try merging invoca .rubocop.yml #508

Merged
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2307dcf
issue #504: bump robocop to v0.91.0 and update cop names to match
ColinDKelley Nov 6, 2020
09b0b34
issue #504: try Invoca's .rubocop.yml; disable a few more cops that d…
ColinDKelley Nov 6, 2020
89c7b77
issue #504: rubocop -a
ColinDKelley Nov 6, 2020
55c3929
issue #504: rubocop -A
ColinDKelley Nov 6, 2020
9573077
issue #504: in .hound.yml, pin rubocop to v0.91.0
ColinDKelley Nov 6, 2020
ab870f5
issue #504: stub warn instead of puts
ColinDKelley Nov 6, 2020
870e8f0
issue #504: address many rubocop offenses
ColinDKelley Nov 6, 2020
a6b6b5d
issue #504: TargetRubyVersion: 2.7
ColinDKelley Nov 6, 2020
e9d888a
issue #504: spell out exception; # rubocop:disable Lint/RescueException
ColinDKelley Nov 23, 2020
a871455
issue #504: rubocop -a
ColinDKelley Nov 23, 2020
f6f144e
issue #504: merge in vendor/hound/config/style_guides/ruby.yml
ColinDKelley Nov 23, 2020
395fdd5
issue #504: move . back to previous line
ColinDKelley Nov 23, 2020
e2b0066
issue #504: sort .rubocop.yml
ColinDKelley Nov 23, 2020
e422472
issue #504: shorten change_fs
ColinDKelley Nov 23, 2020
cfacb88
issue #504: drop some disabled cops; tune MethodLength to 15 with a f…
ColinDKelley Nov 23, 2020
2da3b5e
issue #504: shorten long methods/disable MethodLength cop
ColinDKelley Nov 23, 2020
12df4c4
issue #504: add method_defined?
ColinDKelley Nov 23, 2020
7aa0320
issue #504: add inline rubocop:disable
ColinDKelley Nov 23, 2020
2645262
issue #504: fix cop violations: respond_to_missing?; open
ColinDKelley Nov 23, 2020
5860ed7
issue #504: add newer cops
ColinDKelley Nov 23, 2020
46aa56a
issue #504: rubocop -a -A
ColinDKelley Nov 23, 2020
5b6948b
issue #504: fix keyword arg
ColinDKelley Nov 24, 2020
cd980a7
issue #504: rubocop:disable Lint/MissingSuper
ColinDKelley Nov 24, 2020
c6fe53b
issue #504: remove early returns and private attr_readers
ColinDKelley Nov 24, 2020
ff8450d
issue #504: remove more early returns
ColinDKelley Nov 24, 2020
b2fbfaf
issue #504: fix stubbing to use @_remember_time_of_first_unprocessed_…
ColinDKelley Nov 24, 2020
01cc75b
issue #504: fix *[] refactor bug
ColinDKelley Nov 24, 2020
745d0e3
issue #504: indent if from left; add parens
ColinDKelley Nov 24, 2020
e1045d2
issue #504: set Layout/EndAlignment: EnforcedStyleAlignWith: variable…
ColinDKelley Nov 25, 2020
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
1 change: 1 addition & 0 deletions .hound.yml
@@ -1,3 +1,4 @@
ruby:
enabled: true
version: 0.91.0
config_file: .rubocop.yml
282 changes: 271 additions & 11 deletions .rubocop.yml
@@ -1,19 +1,279 @@
inherit_from:
- vendor/hound/config/style_guides/ruby.yml

# Rails cops
AllCops:
RunRailsCops: false

# Files you want to exclude
AllCops:
TargetRubyVersion: 2.3
TargetRubyVersion: 2.7
Exclude:
- db/schema.rb
- Gemfile
- Guardfile
- Rakefile
- vendor/**/*
UseCache: false

# TODO: put your overrides here:
Layout/AccessModifierIndentation:
IndentationWidth: 2
Layout/BeginEndAlignment:
Enabled: true
Layout/DotPosition:
Enabled: true
EnforcedStyle: trailing
Layout/EmptyLineAfterGuardClause:
Enabled: false
Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true
Layout/HashAlignment:
Enabled: false
Layout/HeredocIndentation:
Enabled: true
Layout/MultilineMethodCallBraceLayout:
Enabled: false
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
Layout/SpaceAroundMethodCallOperator:
Enabled: true
Layout/SpaceInsideBlockBraces:
EnforcedStyleForEmptyBraces: space
Lint/AmbiguousBlockAssociation:
Enabled: false
Lint/AmbiguousRegexpLiteral:
Enabled: false
Lint/AssignmentInCondition:
Enabled: true
AllowSafeAssignment: true
Lint/BinaryOperatorWithIdenticalOperands:
Enabled: true
Lint/ConstantDefinitionInBlock:
Enabled: true
Exclude:
- "**/*_spec.rb"
Lint/DeprecatedOpenSSLConstant:
Enabled: true
Lint/DuplicateElsifCondition:
Enabled: true
Lint/DuplicateRequire:
Enabled: true
Lint/DuplicateRescueException:
Enabled: true
Lint/EmptyConditionalBody:
Enabled: true
Lint/EmptyFile:
Enabled: true
Lint/EmptyWhen:
Enabled: false
Lint/FloatComparison:
Enabled: true
Lint/IdentityComparison:
Enabled: true
Lint/LiteralInInterpolation:
Enabled: false
Lint/MissingSuper:
Enabled: true
Lint/MixedRegexpCaptureTypes:
Enabled: false
Lint/OutOfRangeRegexpRef:
Enabled: true
Lint/RaiseException:
Enabled: true
Lint/RedundantRequireStatement:
Enabled: false
Lint/SelfAssignment:
Enabled: true
Lint/StructNewOverride:
Enabled: true
Lint/SuppressedException:
Enabled: false
Lint/TopLevelReturnWithArgument:
Enabled: true
Lint/TrailingCommaInAttributeDeclaration:
Enabled: true
Lint/UnreachableLoop:
Enabled: true
Lint/UselessMethodDefinition:
Enabled: true
Lint/UselessTimes:
Enabled: true
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Exclude:
- Rakefile
- "**/*.rake"
- "**/*_test.rb"
- "**/*_spec.rb"
Metrics/CyclomaticComplexity:
Max: 10
Metrics/LineLength:
Max: 150
Metrics/MethodLength:
Max: 15
Metrics/ModuleLength:
CountComments: false
Max: 200
Enabled: true
Metrics/ParameterLists:
Enabled: true
Max: 6
Metrics/PerceivedComplexity:
Max: 10
Naming/AccessorMethodName:
Enabled: false
Naming/FileName:
Enabled: false
Exclude: []
Naming/HeredocDelimiterNaming:
Enabled: false
Naming/PredicateName:
Enabled: true
NamePrefix:
- is_
- has_
- have_
ForbiddenPrefixes:
- is_
Exclude:
- spec/**/*
Naming/RescuedExceptionsVariableName:
Enabled: false
Naming/VariableNumber:
Enabled: false
Style/AccessorGrouping:
Enabled: true
Style/Alias:
Enabled: false
Style/AndOr:
EnforcedStyle: conditionals
Style/ArrayCoercion:
Enabled: true
Style/BisectedAttrAccessor:
Enabled: true
Style/CaseLikeIf:
Enabled: true
Style/ClassAndModuleChildren:
Enabled: true
Style/CollectionMethods:
Enabled: true
PreferredMethods:
collect: map
collect!: map!
inject: reduce
detect: find
find_all: select
length: size
Style/CombinableLoops:
Enabled: true
Style/CommentedKeyword:
Enabled: false
Style/Documentation:
Enabled: false
Style/DoubleNegation:
Enabled: false
Style/EachWithObject:
Enabled: false
Style/EmptyMethod:
Enabled: false
Style/ExplicitBlockArgument:
Enabled: true
Style/ExponentialNotation:
Enabled: true
Style/FormatStringToken:
Enabled: false
Style/GlobalStdStream:
Enabled: false
Style/GuardClause:
Enabled: false
Style/HashAsLastArrayItem:
Enabled: true
Style/HashEachMethods:
Enabled: true
Style/HashLikeCase:
Enabled: true
Style/HashSyntax:
EnforcedStyle: ruby19_no_mixed_keys
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
Style/IfUnlessModifier:
Enabled: false
Style/InlineComment:
Enabled: false
Style/KeywordParametersOrder:
Enabled: true
Style/Lambda:
Enabled: false
Style/ModuleFunction:
Enabled: false
Style/NegatedIf:
Enabled: false
Style/Next:
Enabled: false
Style/NumericLiteralPrefix:
Enabled: false
Style/NumericLiterals:
MinDigits: 9
Style/NumericPredicate:
Enabled: false
Style/OneLineConditional:
Enabled: false
Style/OptionalBooleanParameter:
Enabled: true
Style/ParallelAssignment:
Enabled: false
Style/PercentLiteralDelimiters:
Enabled: false
Style/PreferredHashMethods:
Enabled: false
Style/RaiseArgs:
Enabled: false
EnforcedStyle: exploded
Style/RedundantAssignment:
Enabled: true
Style/RedundantFetchBlock:
Enabled: true
Style/RedundantFileExtensionInRequire:
Enabled: true
Style/RedundantRegexpCharacterClass:
Enabled: true
Style/RedundantRegexpEscape:
Enabled: true
Style/RedundantSelfAssignment:
Enabled: true
Style/RegexpLiteral:
Enabled: false
Style/RescueStandardError:
Enabled: false
Style/Send:
Enabled: false
Style/SignalException:
Enabled: false
Style/SingleArgumentDig:
Enabled: true
Style/SingleLineBlockParams:
Enabled: false
Style/SingleLineMethods:
Enabled: false
AllowIfMethodIsEmpty: true
Style/SlicingWithRange:
Enabled: true
Style/SoleNestedConditional:
Enabled: true
Style/StringConcatenation:
Enabled: true
Style/StringLiterals:
Enabled: false
Style/StringLiteralsInInterpolation:
Enabled: true
EnforcedStyle: single_quotes
Style/SymbolArray:
Enabled: false
Style/TrailingCommaInArguments:
Enabled: false
Style/TrailingCommaInArrayLiteral:
Enabled: false
Style/TrailingCommaInHashLiteral:
Enabled: false
Style/TrailingUnderscoreVariable:
Enabled: false
Style/VariableInterpolation:
Enabled: false
Style/WhenThen:
Enabled: false
Style/WordArray:
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -34,6 +34,6 @@ group :development do
gem 'netrc', require: false
gem 'octokit', require: false
gem 'pry-rescue'
gem 'rubocop', '~> 0.49.0' # TODO: should match Gemfile HoundCi
gem 'rubocop', '0.91.0'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can update to 1.2.0, I think there will be not much changes as I have checked in my local machine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the highest supported by hound is 0.91.0.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use something else than hound in that case? Github actions like lint-action.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KapilSachdev That sounds reasonable. So that we don't bog this Issue down, can you file a separate issue for that?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The time i commented about lint-action, i was unaware of one issue that they have i.e. annotations don't work when PR is created from a fork. Which is where most PRs come from. Though there is a new pull_request_target event for that, but it still isn't working (from what i had tried).
shoulda-matcher gem also recently reverted from lint-action (which initially uses hound) and has fallen back to non-annotation based rubocop linting (like what rails uses).

I will create a issue for rubocop linting based on github actions.

gem 'yard', require: false
end
7 changes: 3 additions & 4 deletions bin/listen
@@ -1,12 +1,11 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'listen'
require 'listen/cli'

unless defined?(JRUBY_VERSION)
if Signal.list.keys.include?('INT')
Signal.trap('INT') { Thread.new { Listen.stop } }
end
if !defined?(JRUBY_VERSION) && Signal.list.keys.include?('INT')
Signal.trap('INT') { Thread.new { Listen.stop } }
end

Listen::CLI.start
6 changes: 3 additions & 3 deletions lib/listen/adapter.rb
Expand Up @@ -11,7 +11,7 @@ module Listen
module Adapter
OPTIMIZED_ADAPTERS = [Darwin, Linux, BSD, Windows].freeze
POLLING_FALLBACK_MESSAGE = 'Listen will be polling for changes.'\
'Learn more at https://github.com/guard/listen#listen-adapters.'.freeze
'Learn more at https://github.com/guard/listen#listen-adapters.'

class << self
def select(options = {})
Expand All @@ -24,14 +24,14 @@ def select(options = {})
Polling
rescue
Listen.logger.warn format('Adapter: failed: %s:%s', $ERROR_POSITION.inspect,
$ERROR_POSITION * "\n")
$ERROR_POSITION * "\n")
ColinDKelley marked this conversation as resolved.
Show resolved Hide resolved
raise
end

private

def _usable_adapter_class
OPTIMIZED_ADAPTERS.detect(&:usable?)
OPTIMIZED_ADAPTERS.find(&:usable?)
end

def _warn_polling_fallback(options)
Expand Down
8 changes: 4 additions & 4 deletions lib/listen/adapter/base.rb
Expand Up @@ -8,13 +8,11 @@
module Listen
module Adapter
class Base
attr_reader :options
attr_reader :options, :config

# TODO: only used by tests
DEFAULTS = {}.freeze

attr_reader :config

def initialize(config)
@started = false
@config = config
Expand All @@ -31,6 +29,7 @@ def initialize(config)
end

# TODO: it's a separate method as a temporary workaround for tests
# rubocop:disable Metrics/MethodLength
def configure
if @configured
Listen.logger.warn('Adapter already configured!')
Expand All @@ -57,6 +56,7 @@ def configure
@snapshots[dir] = snapshot
end
end
# rubocop:enable Metrics/MethodLength

def started?
@started
Expand All @@ -73,7 +73,7 @@ def start
@started = true

@run_thread = Listen::Thread.new("run_thread") do
@snapshots.values.each do |snapshot|
@snapshots.each_value do |snapshot|
_timed('Record.build()') { snapshot.record.build }
end
_run
Expand Down