Skip to content

Commit

Permalink
dep: move dev dependencies into Gemfile
Browse files Browse the repository at this point in the history
Pin the dev dependencies so that dependabot will tell us when new
versions are out and we'll get CI results automatically.

Make rubocop dependencies conditional on Ruby 3 to work around the
constraint of rubocop-shopify requiring ruby 2.7 or higher.

Bump rubocop versions and regenerate the rubocop TODO file.
  • Loading branch information
flavorjones committed Aug 23, 2022
1 parent 3b16ed4 commit 31cf417
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 60 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AllCops:
- 'lib/nokogiri/css/parser.rb' # generated by racc
- 'lib/nokogiri/css/tokenizer.rb' # generated by rex
- 'lib/nokogiri/jruby/nokogiri_jars.rb' # generated by jar-dependencies
TargetRubyVersion: "2.6"
Naming/MethodName:
Enabled: false
Naming/FileName:
Expand Down
25 changes: 10 additions & 15 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-04-27 12:13:42 UTC using RuboCop version 1.28.2.
# on 2022-08-23 16:20:00 UTC using RuboCop version 1.35.1.
# 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
Expand All @@ -13,10 +13,10 @@ Lint/MissingSuper:
- 'lib/nokogiri/html5/document_fragment.rb'
- 'lib/nokogiri/xml/document_fragment.rb'

# Offense count: 17
# Offense count: 4
# Configuration parameters: CountBlocks.
Metrics/BlockNesting:
Max: 5
Max: 4

# Offense count: 2
# Configuration parameters: Max, CountKeywordArgs.
Expand All @@ -31,26 +31,21 @@ Performance/CollectionLiteralInLoop:
- 'test/xml/test_dtd_encoding.rb'
- 'test/xml/test_node_reparenting.rb'

# Offense count: 17
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowedVars.
Style/FetchEnvVar:
Exclude:
- 'ext/nokogiri/extconf.rb'
- 'rakelib/debug.rake'
- 'rakelib/extensions.rake'
- 'rakelib/rdoc.rake'
- 'test/helper.rb'
# Offense count: 23
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: def_self, self_class
Style/ClassMethodsDefinitions:
Enabled: false

# Offense count: 2
Style/MissingRespondToMissing:
Exclude:
- 'lib/nokogiri/xml/builder.rb'

# Offense count: 73
# This cop supports safe auto-correction (--auto-correct).
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
# AllowedPatterns: \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z), \A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z)
Layout/LineLength:
Max: 250
32 changes: 32 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,35 @@
source "https://rubygems.org"

gemspec

group :development do
# bootstrapping
gem "bundler", "~> 2.3"
gem "rake", "= 13.0.6"

# building extensions
gem "rake-compiler", "= 1.2.0"
gem "rake-compiler-dock", "= 1.2.2"

# documentation
gem "hoe-markdown", "= 1.4.0"
gem "rdoc", "= 6.4.0"

# parser generator
gem "rexical", "= 1.0.7"

# tests
gem "minitest", "= 5.16.3"
gem "minitest-reporters", "= 1.5.0"
gem "ruby_memcheck", "= 1.0.3"
gem "simplecov", "= 0.21.2"

# rubocop
if Gem::Requirement.new("~> 3.0").satisfied_by?(Gem::Version.new(RUBY_VERSION))
gem "rubocop", "= 1.35.1"
gem "rubocop-minitest", "= 0.21.0"
gem "rubocop-performance", "= 1.14.3"
gem "rubocop-rake", "= 0.6.0"
gem "rubocop-shopify", "= 2.9.0"
end
end
17 changes: 0 additions & 17 deletions nokogiri.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -339,22 +339,5 @@ Gem::Specification.new do |spec|
end
spec.add_runtime_dependency("racc", "~> 1.4")

spec.add_development_dependency("bundler", "~> 2.3")
spec.add_development_dependency("hoe-markdown", "~> 1.4.0")
spec.add_development_dependency("minitest", "~> 5.16.2")
spec.add_development_dependency("minitest-reporters", "~> 1.5.0")
spec.add_development_dependency("rake", "~> 13.0.6")
spec.add_development_dependency("rake-compiler", "= 1.2.0")
spec.add_development_dependency("rake-compiler-dock", "= 1.2.2")
spec.add_development_dependency("rdoc", "~> 6.4.0")
spec.add_development_dependency("rexical", "~> 1.0.7")
spec.add_development_dependency("rubocop", "~> 1.30.1")
spec.add_development_dependency("rubocop-minitest", "~> 0.21.0")
spec.add_development_dependency("rubocop-performance", "~> 1.14.2")
spec.add_development_dependency("rubocop-rake", "~> 0.6.0")
spec.add_development_dependency("rubocop-shopify", "= 2.5.0") # TODO: loosen this after dropping support for Ruby 2.6
spec.add_development_dependency("ruby_memcheck", "~> 1.0.3")
spec.add_development_dependency("simplecov", "~> 0.21.2")

spec.extensions << "ext/nokogiri/extconf.rb"
end
61 changes: 33 additions & 28 deletions rakelib/rubocop.rake
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
# frozen_string_literal: true

require "rubocop/rake_task"
begin
require("rubocop/rake_task")

module RubocopHelper
class << self
def common_options(task)
task.patterns += [
"Gemfile", "Rakefile", "nokogiri.gemspec",
"bin", "ext", "lib", "oci-images", "rakelib", "scripts", "test",
]
end
module RubocopHelper
class << self
def common_options(task)
task.patterns += [
"Gemfile", "Rakefile", "nokogiri.gemspec",
"bin", "ext", "lib", "oci-images", "rakelib", "scripts", "test",
]
end

def generated_files(task)
task.patterns += ["lib/nokogiri/css/parser.rb", "lib/nokogiri/css/tokenizer.rb"]
task.options << "--only=Style/FrozenStringLiteralComment"
def generated_files(task)
task.patterns += ["lib/nokogiri/css/parser.rb", "lib/nokogiri/css/tokenizer.rb"]
task.options << "--only=Style/FrozenStringLiteralComment"
end
end
end
end

namespace "rubocop" do
desc "Generate the rubocop todo list"
RuboCop::RakeTask.new("todo") do |task|
RubocopHelper.common_options(task)
task.options << "--auto-gen-config"
end
Rake::Task["rubocop:todo:auto_correct"].clear
namespace("rubocop") do
desc("Generate the rubocop todo list")
RuboCop::RakeTask.new("todo") do |task|
RubocopHelper.common_options(task)
task.options << "--auto-gen-config"
end
Rake::Task["rubocop:todo:autocorrect"].clear
Rake::Task["rubocop:todo:autocorrect_all"].clear

desc "Run all checks on a subset of directories"
RuboCop::RakeTask.new("check") { |task| RubocopHelper.common_options(task) }
RuboCop::RakeTask.new("check") { |task| RubocopHelper.generated_files(task) }
desc("Run all checks on a subset of directories")
RuboCop::RakeTask.new("check") { |task| RubocopHelper.common_options(task) }
RuboCop::RakeTask.new("check") { |task| RubocopHelper.generated_files(task) }

desc "Shortcut for rubocop:check:auto_correct"
task fix: "rubocop:check:auto_correct"
end
desc("Shortcut for rubocop:check:autocorrect")
task(fix: "rubocop:check:autocorrect")
end

desc "Shortcut for rubocop:check"
task rubocop: "rubocop:check"
desc("Shortcut for rubocop:check")
task(rubocop: "rubocop:check")
rescue LoadError => e
warn("WARNING: rubocop is not available in this environment: #{e}")
end

0 comments on commit 31cf417

Please sign in to comment.