Skip to content

Commit

Permalink
Update dev dependencies (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
sds authored Jan 16, 2024
1 parent 8e17757 commit 2f04c01
Show file tree
Hide file tree
Showing 35 changed files with 143 additions and 97 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ name: CI

on:
push:
branches: [ master ]
branches: [main]
pull_request:
types: [synchronize, opened, reopened, ready_for_review]

jobs:
ci:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest

strategy:
matrix:
ruby-version: ['2.4', '2.5', '2.6', '3.0', '3.1', '3.2.0', jruby]
ruby-version: ['3.0', '3.1', '3.2', '3.3', jruby]

steps:
- uses: actions/checkout@v3
Expand Down
50 changes: 28 additions & 22 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,62 @@
inherit_from: .rubocop_todo.yml

AllCops:
DisplayCopNames: true
TargetRubyVersion: 2.4 # Oldest version of Ruby we support
NewCops: disable

AccessModifierIndentation:
Layout/AccessModifierIndentation:
EnforcedStyle: outdent

AssignmentInCondition:
Lint/AssignmentInCondition:
Enabled: false

# Enforcing this results in a lot of unnecessary indentation.
ClassAndModuleChildren:
Style/ClassAndModuleChildren:
Enabled: false

ClassLength:
Metrics/ClassLength:
Exclude:
- 'lib/scss_lint/config.rb'
- 'lib/scss_lint/cli.rb'

CollectionMethods:
Style/OptionalBooleanParameter:
Enabled: false

Style/CollectionMethods:
PreferredMethods:
reduce: inject

Documentation:
Style/Documentation:
Exclude:
- 'spec/scss_lint/**/*'
- 'spec/scss_lint/linter/**/*'

Eval:
Security/Eval:
Exclude:
- 'lib/scss_lint/sass/script.rb'

FormatString:
Style/FormatString:
Enabled: false

FileName:
Naming/FileName:
Exclude:
- 'bin/scss-lint'
- 'Gemfile'
- 'Rakefile'
- '*.gemspec'

GuardClause:
Style/GuardClause:
Enabled: true

HandleExceptions:
Lint/SuppressedException:
Exclude:
- 'spec/scss_lint/cli_spec.rb'

IfUnlessModifier:
Style/IfUnlessModifier:
Enabled: false

Layout/AlignHash:
Layout/HashAlignment:
Enabled: false

Layout/ClosingHeredocIndentation:
Expand All @@ -63,16 +69,16 @@ Layout/ExtraSpacing:
Exclude:
- '*.gemspec'

Layout/IndentFirstArrayElement:
Layout/FirstArrayElementIndentation:
Enabled: false

Layout/IndentHeredoc:
Layout/HeredocIndentation:
Enabled: false

Layout/MultilineOperationIndentation:
Enabled: false

LineLength:
Layout/LineLength:
Max: 103

# Reports false positives for `'.one #{$interpolated-string} .two .three {}'` (RuboCop v0.50.0)
Expand All @@ -83,10 +89,10 @@ Lint/Void:
Exclude:
- 'spec/**/*_spec.rb'

Naming/UncommunicativeMethodParamName:
Naming/MethodParameterName:
Enabled: false

MethodLength:
Metrics/MethodLength:
Max: 20

Metrics/AbcSize:
Expand All @@ -96,11 +102,11 @@ Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'

PerceivedComplexity:
Metrics/PerceivedComplexity:
Max: 8

# Prefer curly braces except for %i/%w/%W, since those return arrays.
PercentLiteralDelimiters:
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': '{}'
'%i': '[]'
Expand All @@ -114,12 +120,12 @@ PercentLiteralDelimiters:

# Renaming `has_something?` to `something?` obfuscates whether it is a "is-a" or
# a "has-a" relationship.
PredicateName:
Naming/PredicateName:
Enabled: false

# Forcing a particular name (e.g. |a, e|) for inject methods prevents you from
# choosing intention-revealing names.
SingleLineBlockParams:
Style/SingleLineBlockParams:
Enabled: false

# YAML.safe_load isn't available on Ruby 2.0.0, which we still support
Expand Down
45 changes: 45 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-01-16 23:49:35 UTC using RuboCop version 1.60.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 26
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'spec/scss_lint/cli_spec.rb'
- 'spec/scss_lint/config_spec.rb'
- 'spec/scss_lint/linter_registry_spec.rb'
- 'spec/scss_lint/linter_spec.rb'
- 'spec/scss_lint/reporter/stats_reporter_spec.rb'
- 'spec/scss_lint/reporter_spec.rb'
- 'spec/scss_lint/runner_spec.rb'
- 'spec/scss_lint/selector_visitor_spec.rb'

# Offense count: 1
Lint/FormatParameterMismatch:
Exclude:
- 'lib/scss_lint/reporter/stats_reporter.rb'

# Offense count: 3
# Configuration parameters: AllowedParentClasses.
Lint/MissingSuper:
Exclude:
- 'lib/scss_lint/linter.rb'
- 'lib/scss_lint/rake_task.rb'

# Offense count: 3
Lint/MixedRegexpCaptureTypes:
Exclude:
- 'lib/scss_lint/control_comment_processor.rb'
- 'lib/scss_lint/linter/disable_linter_reason.rb'
- 'lib/scss_lint/linter/property_sort_order.rb'

# Offense count: 1
Style/ClassVars:
Exclude:
- 'lib/scss_lint/selector_visitor.rb'
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ gemspec
gem 'rspec', '~> 3.8'

# Run all pre-commit checks via Overcommit during CI runs
gem 'overcommit', '0.51.0'
gem 'overcommit', '0.62.0'

# Needed to test Rake integration in specs
gem 'rake'

# Pin tool versions (which are executed by Overcommit) for Travis builds
gem 'rubocop', '0.74.0'
gem 'rubocop', '1.60.0'

gem 'coveralls', require: false
2 changes: 1 addition & 1 deletion bin/scss-lint
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
require 'scss_lint'
require 'scss_lint/cli'

logger = SCSSLint::Logger.new(STDOUT)
logger = SCSSLint::Logger.new($stdout)
exit SCSSLint::CLI.new(logger).run(ARGV)
6 changes: 3 additions & 3 deletions lib/scss_lint/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def scan_for_lints(options, config)

def files_to_lint(options, config)
if options[:stdin_file_path]
[{ file: STDIN, path: options[:stdin_file_path] }]
[{ file: $stdin, path: options[:stdin_file_path] }]
else
patterns = Array(options[:files]).any? ? Array(options[:files]) : config.scss_files
FileFinder.new(config).find(patterns).map do |file_path|
Expand All @@ -87,7 +87,7 @@ def files_to_lint(options, config)
end
end

def handle_runtime_exception(exception, options) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/LineLength, Metrics/MethodLength
def handle_runtime_exception(exception, options) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
case exception
when SCSSLint::Exceptions::InvalidCLIOption
log.error exception.message
Expand Down Expand Up @@ -213,7 +213,7 @@ def load_required_paths(options)
def load_reporters(options)
options[:reporters].map! do |reporter_name, output_file|
begin
reporter = SCSSLint::Reporter.const_get(reporter_name + 'Reporter')
reporter = SCSSLint::Reporter.const_get("#{reporter_name}Reporter")
rescue NameError
raise SCSSLint::Exceptions::InvalidCLIOption,
"Invalid output format specified: #{reporter_name}"
Expand Down
2 changes: 1 addition & 1 deletion lib/scss_lint/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def convert_single_options_to_arrays(options)
def merge_wildcard_linter_options(options)
options = options.dup
# Cannot use `each_key` because the cycle adds new keys during iteration
options.fetch('linters', {}).keys.each do |class_name|
options.fetch('linters', {}).keys.each do |class_name| # rubocop:disable Style/HashEachMethods
next unless class_name.include?('*')

wildcard_options = options['linters'].delete(class_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/scss_lint/control_comment_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def extract_commands(node)
//\s*scss-lint:
(?<action>disable|enable)\s+
(?<linters>.*?)
\s*($|\*\/) # End of line
\s*($|\*/) # End of line
}x.match(comment_line)

commands << {
Expand Down
2 changes: 1 addition & 1 deletion lib/scss_lint/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def find_any_control_commands
@lines.any? { |line| line['scss-lint:disable'] || line['scss-lint:enable'] }
end

def preprocess_contents # rubocop:disable CyclomaticComplexity
def preprocess_contents # rubocop:disable Metrics/CyclomaticComplexity
return unless @preprocess_command
# Never preprocess :code scss if @preprocess_files is specified.
return if @preprocess_files && @filename.nil?
Expand Down
2 changes: 1 addition & 1 deletion lib/scss_lint/linter.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module SCSSLint
# Defines common functionality available to all linters.
class Linter < Sass::Tree::Visitors::Base # rubocop:disable ClassLength
class Linter < Sass::Tree::Visitors::Base # rubocop:disable Metrics/ClassLength
include SelectorVisitor
include Utils

Expand Down
4 changes: 2 additions & 2 deletions lib/scss_lint/linter/color_variable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def visit_script_color(node)

def visit_script_string(node)
return if literal_string?(node)
remove_quoted_strings(node.value)
remove_quoted_strings(node.value) # rubocop:disable Style/HashEachMethods
.scan(/(^|\s)(#[a-f0-9]+|[a-z]+)(?=\s|$)/i)
.select { |_, word| color?(word) }
.each { |_, color| record_lint(node, color) }
.each { |_, color| record_lint(node, color) }
end

def visit_script_funcall(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/scss_lint/linter/import_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def compose_message(orig_filename)
fixed_basename = orig_basename

if config['leading_underscore']
fixed_basename = '_' + fixed_basename unless fixed_basename.start_with?('_')
fixed_basename = "_#{fixed_basename}" unless fixed_basename.start_with?('_')
else
fixed_basename = fixed_basename.sub(/^_/, '')
end
Expand Down
10 changes: 4 additions & 6 deletions lib/scss_lint/linter/indentation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module SCSSLint
# Checks for consistent indentation of nested declarations and rule sets.
class Linter::Indentation < Linter # rubocop:disable ClassLength
class Linter::Indentation < Linter # rubocop:disable Metrics/ClassLength
include LinterRegistry

def visit_root(_node)
Expand Down Expand Up @@ -165,11 +165,9 @@ def check_arbitrary_indent(node, actual_indent)
# as it's a multiple of the indent width
def check_root_ruleset_indent(node, actual_indent)
# Whether node is a ruleset not nested within any other ruleset.
if @indent == 0 && node.is_a?(Sass::Tree::RuleNode)
unless actual_indent % @indent_width == 0
add_lint(node.line, lint_message("a multiple of #{@indent_width}", actual_indent))
return true
end
if @indent == 0 && node.is_a?(Sass::Tree::RuleNode) && actual_indent % @indent_width != 0
add_lint(node.line, lint_message("a multiple of #{@indent_width}", actual_indent))
return true
end

false
Expand Down
6 changes: 3 additions & 3 deletions lib/scss_lint/linter/private_naming_convention.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module SCSSLint
# Verifies that variables, functions, and mixins that follow the private
# naming convention are defined and used within the same file.
class Linter::PrivateNamingConvention < Linter # rubocop:disable ClassLength
class Linter::PrivateNamingConvention < Linter # rubocop:disable Metrics/ClassLength
include LinterRegistry

DEFINITIONS = {
Expand All @@ -19,7 +19,7 @@ class Linter::PrivateNamingConvention < Linter # rubocop:disable ClassLength
},
}.freeze

HUMAN_NODE_NAMES = Hash[DEFINITIONS.map { |k, v| [k, v[:human_name]] }].freeze
HUMAN_NODE_NAMES = DEFINITIONS.transform_values { |v| v[:human_name] }.freeze
DEFINED_BYS = Hash[DEFINITIONS.map { |k, v| [v[:defines], k] }].freeze

def visit_root(node)
Expand Down Expand Up @@ -99,7 +99,7 @@ def node_defined_earlier_in_branch?(node_to_look_in, looking_for)
# defining node that matches in name and type.
node_to_look_in.children.each do |child_node|
break unless before?(child_node, looking_for[:location])
next unless child_node.class == looking_for[:defined_by]
next unless child_node.instance_of?(looking_for[:defined_by])
next unless child_node.name == looking_for[:node].name

return true # We found a match, so we are done
Expand Down
4 changes: 2 additions & 2 deletions lib/scss_lint/linter/property_sort_order.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module SCSSLint
# Checks the declaration order of properties.
class Linter::PropertySortOrder < Linter # rubocop:disable ClassLength
class Linter::PropertySortOrder < Linter # rubocop:disable Metrics/ClassLength
include LinterRegistry

def visit_root(_node)
Expand Down Expand Up @@ -90,7 +90,7 @@ def check_sort_order(sortable_prop_info)
end
end

def check_group_separation(sortable_prop_info) # rubocop:disable AbcSize
def check_group_separation(sortable_prop_info) # rubocop:disable Metrics/AbcSize
group_number = @group[sortable_prop_info.first[:property]]

sortable_prop_info[0..-2].zip(sortable_prop_info[1..-1]).each do |first, second|
Expand Down
2 changes: 1 addition & 1 deletion lib/scss_lint/linter/property_spelling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def visit_prop(node)

private

def check_property(node, prefix = nil) # rubocop:disable CyclomaticComplexity
def check_property(node, prefix = nil)
return if contains_interpolation?(node)

name = prefix ? "#{prefix}-" : ''
Expand Down
Loading

0 comments on commit 2f04c01

Please sign in to comment.