Upgrade Rubocop
This commit is contained in:
parent
3696c1c10d
commit
c36b40c5f6
|
@ -13,6 +13,7 @@ AllCops:
|
|||
# Other
|
||||
- 'test/benchmarks/**/*'
|
||||
- 'test/profilers/**/*'
|
||||
TargetRubyVersion: 2.6
|
||||
|
||||
# I often use @_variable to avoid clashing.
|
||||
Naming/MemoizedInstanceVariableName:
|
||||
|
|
|
@ -15,12 +15,6 @@ Layout/LineLength:
|
|||
- 'test/**/*_test.rb'
|
||||
Max: 100
|
||||
|
||||
Lint/ConstantDefinitionInBlock:
|
||||
Exclude:
|
||||
- 'Rakefile'
|
||||
- 'spec/**/*'
|
||||
- 'test/**/*'
|
||||
|
||||
# [codesmell]
|
||||
Metrics/AbcSize:
|
||||
Enabled: false
|
||||
|
@ -101,12 +95,6 @@ Layout/EmptyLinesAroundModuleBody:
|
|||
Layout/EmptyLineBetweenDefs:
|
||||
Enabled: false
|
||||
|
||||
# I personally don't care about the format style.
|
||||
# In most cases I like to use %, but not at the point I want to enforce it
|
||||
# as a convention in the entire code.
|
||||
Style/FormatString:
|
||||
Enabled: false
|
||||
|
||||
# Annotated tokens (like %<foo>s) are a good thing, but in most cases we don't need them.
|
||||
# %s is a simpler and straightforward version that works in almost all cases. So don't complain.
|
||||
Style/FormatStringToken:
|
||||
|
@ -116,11 +104,6 @@ Style/FormatStringToken:
|
|||
Style/NegatedIf:
|
||||
Enabled: false
|
||||
|
||||
# For years, %w() has been the de-facto standard. A lot of libraries are using ().
|
||||
# Switching to [] would be a nightmare.
|
||||
Style/PercentLiteralDelimiters:
|
||||
Enabled: false
|
||||
|
||||
# There are cases were the inline rescue is ok. We can either downgrade the severity,
|
||||
# or rely on the developer judgement on a case-by-case basis.
|
||||
Style/RescueModifier:
|
||||
|
@ -129,17 +112,6 @@ Style/RescueModifier:
|
|||
Style/SymbolArray:
|
||||
EnforcedStyle: brackets
|
||||
|
||||
# Sorry, but using trailing spaces helps readability.
|
||||
#
|
||||
# %w( foo bar )
|
||||
#
|
||||
# looks better to me than
|
||||
#
|
||||
# %w( foo bar )
|
||||
#
|
||||
Layout/SpaceInsidePercentLiteralDelimiters:
|
||||
Enabled: false
|
||||
|
||||
# Hate It or Love It, I prefer double quotes as this is more consistent
|
||||
# with several other programming languages and the output of puts and inspect.
|
||||
Style/StringLiterals:
|
||||
|
|
|
@ -3,6 +3,13 @@
|
|||
This project uses [Semantic Versioning 2.0.0](https://semver.org/).
|
||||
|
||||
|
||||
## main
|
||||
|
||||
### Changed
|
||||
|
||||
- Minimum Ruby version is 2.6
|
||||
|
||||
|
||||
## 4.0.7
|
||||
|
||||
### Fixes
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -10,5 +10,5 @@ gem "memory_profiler", require: false
|
|||
gem "minitest"
|
||||
gem "minitest-reporters"
|
||||
gem "mocha"
|
||||
gem "rubocop", "~>0.90", require: false
|
||||
gem "rubocop", require: false
|
||||
gem "yard"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
## Requirements
|
||||
|
||||
<tt>PublicSuffix</tt> requires **Ruby >= 2.3**. For an older versions of Ruby use a previous release.
|
||||
<tt>PublicSuffix</tt> requires **Ruby >= 2.6**. For an older versions of Ruby use a previous release.
|
||||
|
||||
|
||||
## Installation
|
||||
|
|
6
Rakefile
6
Rakefile
|
@ -9,7 +9,7 @@ task default: [:test, :rubocop]
|
|||
require "rake/testtask"
|
||||
|
||||
Rake::TestTask.new do |t|
|
||||
t.libs = %w( lib test )
|
||||
t.libs = %w[lib test]
|
||||
t.pattern = "test/**/*_test.rb"
|
||||
t.verbose = !ENV["VERBOSE"].nil?
|
||||
t.warning = !ENV["WARNING"].nil?
|
||||
|
@ -42,10 +42,10 @@ desc "Downloads the Public Suffix List file from the repository and stores it lo
|
|||
task :"update-list" do
|
||||
require "net/http"
|
||||
|
||||
DEFINITION_URL = "https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat"
|
||||
definition_url = "https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat"
|
||||
|
||||
File.open("data/list.txt", "w+") do |f|
|
||||
response = Net::HTTP.get_response(URI.parse(DEFINITION_URL))
|
||||
response = Net::HTTP.get_response(URI.parse(definition_url))
|
||||
response.body
|
||||
f.write(response.body)
|
||||
end
|
||||
|
|
|
@ -169,7 +169,7 @@ module PublicSuffix
|
|||
|
||||
return DomainInvalid.new("Name is blank") if name.empty?
|
||||
return DomainInvalid.new("Name starts with a dot") if name.start_with?(DOT)
|
||||
return DomainInvalid.new("%s is not expected to contain a scheme" % name) if name.include?("://")
|
||||
return DomainInvalid.new(format("%s is not expected to contain a scheme", name)) if name.include?("://")
|
||||
|
||||
name
|
||||
end
|
||||
|
|
|
@ -221,7 +221,7 @@ module PublicSuffix
|
|||
# @param content [String] the content of the rule
|
||||
# @param private [Boolean]
|
||||
def self.build(content, private: false)
|
||||
new(value: content.to_s[2..-1], private: private)
|
||||
new(value: content.to_s[2..], private: private)
|
||||
end
|
||||
|
||||
# Initializes a new rule.
|
||||
|
@ -269,7 +269,7 @@ module PublicSuffix
|
|||
# @param content [#to_s] the content of the rule
|
||||
# @param private [Boolean]
|
||||
def self.build(content, private: false)
|
||||
new(value: content.to_s[1..-1], private: private)
|
||||
new(value: content.to_s[1..], private: private)
|
||||
end
|
||||
|
||||
# Gets the original rule definition.
|
||||
|
@ -299,7 +299,7 @@ module PublicSuffix
|
|||
#
|
||||
# @return [Array<String>]
|
||||
def parts
|
||||
@value.split(DOT)[1..-1]
|
||||
@value.split(DOT)[1..]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|||
"source_code_uri" => "https://github.com/weppos/publicsuffix-ruby/tree/v#{s.version}",
|
||||
}
|
||||
|
||||
s.required_ruby_version = ">= 2.3"
|
||||
s.required_ruby_version = ">= 2.6"
|
||||
|
||||
s.require_paths = ["lib"]
|
||||
s.files = `git ls-files`.split("\n")
|
||||
|
|
|
@ -64,7 +64,7 @@ class AcceptanceTest < Minitest::Test
|
|||
def test_rejected
|
||||
REJECTED_CASES.each do |name, expected|
|
||||
assert_equal expected, PublicSuffix.valid?(name),
|
||||
"Expected %s to be %s" % [name.inspect, expected.inspect]
|
||||
format("Expected %s to be %s", name.inspect, expected.inspect)
|
||||
assert !valid_domain?(name),
|
||||
"#{name} expected to be invalid"
|
||||
end
|
||||
|
@ -72,9 +72,9 @@ class AcceptanceTest < Minitest::Test
|
|||
|
||||
|
||||
CASE_CASES = [
|
||||
["Www.google.com", %w( www google com )],
|
||||
["www.Google.com", %w( www google com )],
|
||||
["www.google.Com", %w( www google com )],
|
||||
["Www.google.com", %w[www google com]],
|
||||
["www.Google.com", %w[www google com]],
|
||||
["www.google.Com", %w[www google com]],
|
||||
].freeze
|
||||
|
||||
def test_ignore_case
|
||||
|
|
|
@ -45,7 +45,7 @@ class PslTest < Minitest::Test
|
|||
end
|
||||
|
||||
message = "The following #{failures.size} tests fail:\n"
|
||||
failures.each { |i, o, d| message += "Expected %s to be %s, got %s\n" % [i.inspect, o.inspect, d.inspect] }
|
||||
failures.each { |i, o, d| message += format("Expected %s to be %s, got %s\n", i.inspect, o.inspect, d.inspect) }
|
||||
assert_equal 0, failures.size, message
|
||||
end
|
||||
|
||||
|
|
|
@ -10,15 +10,15 @@ class PublicSuffix::DomainTest < Minitest::Test
|
|||
|
||||
# Tokenizes given input into labels.
|
||||
def test_self_name_to_labels
|
||||
assert_equal %w( someone spaces live com ),
|
||||
assert_equal %w[someone spaces live com],
|
||||
PublicSuffix::Domain.name_to_labels("someone.spaces.live.com")
|
||||
assert_equal %w( leontina23samiko wiki zoho com ),
|
||||
assert_equal %w[leontina23samiko wiki zoho com],
|
||||
PublicSuffix::Domain.name_to_labels("leontina23samiko.wiki.zoho.com")
|
||||
end
|
||||
|
||||
# Converts input into String.
|
||||
def test_self_name_to_labels_converts_input_to_string
|
||||
assert_equal %w( someone spaces live com ),
|
||||
assert_equal %w[someone spaces live com],
|
||||
PublicSuffix::Domain.name_to_labels(:"someone.spaces.live.com")
|
||||
end
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ LIST
|
|||
assert_instance_of PublicSuffix::List, list
|
||||
assert_equal 4, list.size
|
||||
|
||||
rules = %w( com *.uk !british-library.uk blogspot.com ).map { |name| PublicSuffix::Rule.factory(name) }
|
||||
rules = %w[com *.uk !british-library.uk blogspot.com].map { |name| PublicSuffix::Rule.factory(name) }
|
||||
assert_equal rules, list.each.to_a
|
||||
|
||||
# private domains
|
||||
|
|
|
@ -29,8 +29,8 @@ class PublicSuffix::RuleTest < Minitest::Test
|
|||
def test_default_returns_default_wildcard
|
||||
default = PublicSuffix::Rule.default
|
||||
assert_equal PublicSuffix::Rule::Wildcard.build("*"), default
|
||||
assert_equal %w( example tldnotlisted ), default.decompose("example.tldnotlisted")
|
||||
assert_equal %w( www.example tldnotlisted ), default.decompose("www.example.tldnotlisted")
|
||||
assert_equal %w[example tldnotlisted], default.decompose("example.tldnotlisted")
|
||||
assert_equal %w[www.example tldnotlisted], default.decompose("www.example.tldnotlisted")
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -140,15 +140,15 @@ class PublicSuffix::RuleNormalTest < Minitest::Test
|
|||
end
|
||||
|
||||
def test_parts
|
||||
assert_equal %w(com), @klass.build("com").parts
|
||||
assert_equal %w(co com), @klass.build("co.com").parts
|
||||
assert_equal %w(mx co com), @klass.build("mx.co.com").parts
|
||||
assert_equal %w[com], @klass.build("com").parts
|
||||
assert_equal %w[co com], @klass.build("co.com").parts
|
||||
assert_equal %w[mx co com], @klass.build("mx.co.com").parts
|
||||
end
|
||||
|
||||
def test_decompose
|
||||
assert_equal [nil, nil], @klass.build("com").decompose("com")
|
||||
assert_equal %w( example com ), @klass.build("com").decompose("example.com")
|
||||
assert_equal %w( foo.example com ), @klass.build("com").decompose("foo.example.com")
|
||||
assert_equal %w[example com], @klass.build("com").decompose("example.com")
|
||||
assert_equal %w[foo.example com], @klass.build("com").decompose("foo.example.com")
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -175,14 +175,14 @@ class PublicSuffix::RuleExceptionTest < Minitest::Test
|
|||
end
|
||||
|
||||
def test_parts
|
||||
assert_equal %w( uk ), @klass.build("!british-library.uk").parts
|
||||
assert_equal %w( tokyo jp ), @klass.build("!metro.tokyo.jp").parts
|
||||
assert_equal %w[uk], @klass.build("!british-library.uk").parts
|
||||
assert_equal %w[tokyo jp], @klass.build("!metro.tokyo.jp").parts
|
||||
end
|
||||
|
||||
def test_decompose
|
||||
assert_equal [nil, nil], @klass.build("!british-library.uk").decompose("uk")
|
||||
assert_equal %w( british-library uk ), @klass.build("!british-library.uk").decompose("british-library.uk")
|
||||
assert_equal %w( foo.british-library uk ), @klass.build("!british-library.uk").decompose("foo.british-library.uk")
|
||||
assert_equal %w[british-library uk], @klass.build("!british-library.uk").decompose("british-library.uk")
|
||||
assert_equal %w[foo.british-library uk], @klass.build("!british-library.uk").decompose("foo.british-library.uk")
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -209,14 +209,14 @@ class PublicSuffix::RuleWildcardTest < Minitest::Test
|
|||
end
|
||||
|
||||
def test_parts
|
||||
assert_equal %w( uk ), @klass.build("*.uk").parts
|
||||
assert_equal %w( co uk ), @klass.build("*.co.uk").parts
|
||||
assert_equal %w[uk], @klass.build("*.uk").parts
|
||||
assert_equal %w[co uk], @klass.build("*.co.uk").parts
|
||||
end
|
||||
|
||||
def test_decompose
|
||||
assert_equal [nil, nil], @klass.build("*.do").decompose("nic.do")
|
||||
assert_equal %w( google co.uk ), @klass.build("*.uk").decompose("google.co.uk")
|
||||
assert_equal %w( foo.google co.uk ), @klass.build("*.uk").decompose("foo.google.co.uk")
|
||||
assert_equal %w[google co.uk], @klass.build("*.uk").decompose("google.co.uk")
|
||||
assert_equal %w[foo.google co.uk], @klass.build("*.uk").decompose("foo.google.co.uk")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue