Configure some new cops (#9688)

Merge pull request 9688
This commit is contained in:
Ashwin Maroli 2024-10-17 18:40:15 +05:30 committed by GitHub
parent fce1966b3a
commit 5e1b6d3fae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 109 additions and 11 deletions

View File

@ -41,6 +41,8 @@ Jekyll/NoPutsAllowed:
# ---------------------------------------- # ----------------------------------------
Gemspec/DeprecatedAttributeAssignment: Gemspec/DeprecatedAttributeAssignment:
Enabled: true Enabled: true
Gemspec/DevelopmentDependencies:
Enabled: false
Gemspec/RequireMFA: Gemspec/RequireMFA:
Enabled: false Enabled: false
@ -54,6 +56,8 @@ Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true Enabled: true
Layout/EndAlignment: Layout/EndAlignment:
Severity: error Severity: error
Layout/EndOfLine:
Enabled: false
Layout/FirstArrayElementIndentation: Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent EnforcedStyle: consistent
Layout/FirstHashElementIndentation: Layout/FirstHashElementIndentation:
@ -113,6 +117,10 @@ Lint/DuplicateBranch:
Enabled: true Enabled: true
Lint/DuplicateElsifCondition: Lint/DuplicateElsifCondition:
Enabled: true Enabled: true
Lint/DuplicateMagicComment:
Enabled: true
Lint/DuplicateMatchPattern:
Enabled: true
Lint/DuplicateRegexpCharacterClassElement: Lint/DuplicateRegexpCharacterClassElement:
Enabled: true Enabled: true
Lint/DuplicateRequire: Lint/DuplicateRequire:
@ -137,6 +145,8 @@ Lint/LambdaWithoutLiteralBlock:
Enabled: true Enabled: true
Lint/MissingSuper: Lint/MissingSuper:
Enabled: false Enabled: false
Lint/MixedCaseRange:
Enabled: true
Lint/MixedRegexpCaptureTypes: Lint/MixedRegexpCaptureTypes:
Enabled: false Enabled: false
Lint/NestedPercentLiteral: Lint/NestedPercentLiteral:
@ -154,8 +164,12 @@ Lint/RaiseException:
Enabled: true Enabled: true
Lint/RedundantDirGlobSort: Lint/RedundantDirGlobSort:
Enabled: true Enabled: true
Lint/RedundantRegexpQuantifiers:
Enabled: true
Lint/RedundantSafeNavigation: Lint/RedundantSafeNavigation:
Enabled: true Enabled: true
Lint/RefinementImportMethods:
Enabled: true
Lint/RequireRangeParentheses: Lint/RequireRangeParentheses:
Enabled: true Enabled: true
Lint/RequireRelativeSelfPath: Lint/RequireRelativeSelfPath:
@ -184,6 +198,8 @@ Lint/UnreachableLoop:
Enabled: true Enabled: true
Lint/UselessMethodDefinition: Lint/UselessMethodDefinition:
Enabled: true Enabled: true
Lint/UselessRuby2Keywords:
Enabled: true
Lint/UselessTimes: Lint/UselessTimes:
Enabled: true Enabled: true
Lint/Void: Lint/Void:
@ -208,6 +224,8 @@ Metrics/ClassLength:
- lib/jekyll/site.rb - lib/jekyll/site.rb
- test/**/*.rb - test/**/*.rb
Max: 240 Max: 240
Metrics/CollectionLiteralLength:
Enabled: true
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Exclude: Exclude:
- lib/jekyll/commands/serve.rb - lib/jekyll/commands/serve.rb
@ -234,32 +252,70 @@ Minitest/AssertInDelta:
Enabled: true Enabled: true
Minitest/AssertKindOf: Minitest/AssertKindOf:
Enabled: true Enabled: true
Minitest/AssertOperator:
Enabled: false
Minitest/AssertOutput: Minitest/AssertOutput:
Enabled: true Enabled: true
Minitest/AssertPathExists: Minitest/AssertPathExists:
Enabled: true Enabled: true
Minitest/AssertPredicate:
Enabled: false
Minitest/AssertRaisesWithRegexpArgument:
Enabled: true
Minitest/AssertSame:
Enabled: true
Minitest/AssertSilent: Minitest/AssertSilent:
Enabled: true Enabled: true
Minitest/AssertWithExpectedArgument: Minitest/AssertWithExpectedArgument:
Enabled: true Enabled: true
Minitest/AssertionInLifecycleHook: Minitest/AssertionInLifecycleHook:
Enabled: true Enabled: true
Minitest/DuplicateTestRun:
Enabled: true
Minitest/EmptyLineBeforeAssertionMethods:
Enabled: false
Minitest/LifecycleHooksOrder:
Enabled: true
Minitest/LiteralAsActualArgument: Minitest/LiteralAsActualArgument:
Enabled: true Enabled: true
Minitest/MultipleAssertions: Minitest/MultipleAssertions:
Enabled: true Enabled: true
Minitest/NonExecutableTestMethod:
Enabled: true
Minitest/NonPublicTestMethod:
Enabled: true
Minitest/RedundantMessageArgument:
Enabled: true
Minitest/RefuteInDelta: Minitest/RefuteInDelta:
Enabled: true Enabled: true
Minitest/RefuteKindOf: Minitest/RefuteKindOf:
Enabled: true Enabled: true
Minitest/RefuteOperator:
Enabled: false
Minitest/RefutePathExists: Minitest/RefutePathExists:
Enabled: true Enabled: true
Minitest/RefutePredicate:
Enabled: false
Minitest/RefuteSame:
Enabled: true
Minitest/ReturnInTestMethod:
Enabled: true
Minitest/SkipEnsure:
Enabled: true
Minitest/SkipWithoutReason:
Enabled: true
Minitest/TestFileName:
Enabled: true
Exclude:
- test/helper.rb
Minitest/TestMethodName: Minitest/TestMethodName:
Enabled: false Enabled: false
Minitest/UnreachableAssertion: Minitest/UnreachableAssertion:
Enabled: true Enabled: true
Minitest/UnspecifiedException: Minitest/UnspecifiedException:
Enabled: true Enabled: true
Minitest/UselessAssertion:
Enabled: true
# Naming cops # Naming cops
# ---------------------------------------- # ----------------------------------------
@ -293,6 +349,8 @@ Performance/ConstantRegexp:
Enabled: true Enabled: true
Performance/MapCompact: Performance/MapCompact:
Enabled: true Enabled: true
Performance/MapMethodChain:
Enabled: true
Performance/MethodObjectAsBlock: Performance/MethodObjectAsBlock:
Enabled: true Enabled: true
Performance/RedundantEqualityComparisonBlock: Performance/RedundantEqualityComparisonBlock:
@ -347,6 +405,8 @@ Style/ArgumentsForwarding:
Enabled: false Enabled: false
Style/ArrayCoercion: Style/ArrayCoercion:
Enabled: true Enabled: true
Style/ArrayIntersect:
Enabled: true
Style/BisectedAttrAccessor: Style/BisectedAttrAccessor:
Enabled: true Enabled: true
Style/CaseLikeIf: Style/CaseLikeIf:
@ -360,6 +420,10 @@ Style/CollectionCompact:
Enabled: true Enabled: true
Style/CombinableLoops: Style/CombinableLoops:
Enabled: true Enabled: true
Style/ConcatArrayLiterals:
Enabled: true
Style/DirEmpty:
Enabled: true
Style/DocumentDynamicEvalDefinition: Style/DocumentDynamicEvalDefinition:
Enabled: true Enabled: true
Style/Documentation: Style/Documentation:
@ -372,12 +436,16 @@ Style/EndlessMethod:
Enabled: true Enabled: true
Style/EnvHome: Style/EnvHome:
Enabled: true Enabled: true
Style/ExactRegexpMatch:
Enabled: true
Style/ExplicitBlockArgument: Style/ExplicitBlockArgument:
Enabled: false Enabled: false
Style/ExponentialNotation: Style/ExponentialNotation:
Enabled: true Enabled: true
Style/FetchEnvVar: Style/FetchEnvVar:
Enabled: false Enabled: false
Style/FileEmpty:
Enabled: true
Style/FileRead: Style/FileRead:
Enabled: false Enabled: false
Style/FileWrite: Style/FileWrite:
@ -435,6 +503,10 @@ Style/NestedFileDirname:
Enabled: true Enabled: true
Style/NilLambda: Style/NilLambda:
Enabled: true Enabled: true
Style/ObjectThen:
Enabled: true
Style/OperatorMethodCall:
Enabled: true
Style/OptionalBooleanParameter: Style/OptionalBooleanParameter:
Enabled: true Enabled: true
Exclude: Exclude:
@ -452,28 +524,52 @@ Style/QuotedSymbols:
Enabled: true Enabled: true
Style/RedundantArgument: Style/RedundantArgument:
Enabled: true Enabled: true
Style/RedundantArrayConstructor:
Enabled: true
Style/RedundantAssignment: Style/RedundantAssignment:
Enabled: true Enabled: true
Style/RedundantConstantBase:
Enabled: true
Style/RedundantCurrentDirectoryInPath:
Enabled: true
Style/RedundantDoubleSplatHashBraces:
Enabled: true
Style/RedundantEach:
Enabled: true
Style/RedundantFetchBlock: Style/RedundantFetchBlock:
Enabled: false Enabled: false
Style/RedundantFileExtensionInRequire: Style/RedundantFileExtensionInRequire:
Enabled: true Enabled: true
Style/RedundantFilterChain:
Enabled: true
Style/RedundantHeredocDelimiterQuotes:
Enabled: true
Style/RedundantInitialize: Style/RedundantInitialize:
Enabled: true Enabled: true
Exclude: Exclude:
- lib/jekyll/plugin.rb - lib/jekyll/plugin.rb
Style/RedundantLineContinuation:
Enabled: true
Style/RedundantRegexpArgument:
Enabled: true
Style/RedundantRegexpCharacterClass: Style/RedundantRegexpCharacterClass:
Enabled: true Enabled: true
Style/RedundantRegexpConstructor:
Enabled: true
Style/RedundantRegexpEscape: Style/RedundantRegexpEscape:
Enabled: true Enabled: true
Style/RedundantSelfAssignment: Style/RedundantSelfAssignment:
Enabled: true Enabled: true
Style/RedundantSelfAssignmentBranch: Style/RedundantSelfAssignmentBranch:
Enabled: true Enabled: true
Style/RedundantStringEscape:
Enabled: true
Style/RegexpLiteral: Style/RegexpLiteral:
EnforcedStyle: percent_r EnforcedStyle: percent_r
Style/RescueModifier: Style/RescueModifier:
Enabled: false Enabled: false
Style/ReturnNilInPredicateMethodDefinition:
Enabled: true
Style/SafeNavigation: Style/SafeNavigation:
Exclude: Exclude:
- lib/jekyll/document.rb - lib/jekyll/document.rb
@ -482,6 +578,8 @@ Style/SignalException:
EnforcedStyle: only_raise EnforcedStyle: only_raise
Style/SingleArgumentDig: Style/SingleArgumentDig:
Enabled: true Enabled: true
Style/SingleLineDoEndBlock:
Enabled: true
Style/SlicingWithRange: Style/SlicingWithRange:
Enabled: false Enabled: false
Style/SoleNestedConditional: Style/SoleNestedConditional:

View File

@ -83,7 +83,7 @@ module Jekyll
# Returns an array of strings, each string being the name of a gem name # Returns an array of strings, each string being the name of a gem name
# that is allowed to be used. # that is allowed to be used.
def whitelist def whitelist
@whitelist ||= Array[site.config["whitelist"]].flatten @whitelist ||= [site.config["whitelist"]].flatten
end end
# Require all .rb files if safe mode is off # Require all .rb files if safe mode is off

View File

@ -78,7 +78,7 @@ class TestTagLink < TagUnitTest
{% assign contacts_ext = 'html' %} {% assign contacts_ext = 'html' %}
{% link {{contacts_filename}}.{{contacts_ext}} %} {% link {{contacts_filename}}.{{contacts_ext}} %}
{% assign info_path = 'info.md' %} {% assign info_path = 'info.md' %}
{% link {{\ info_path\ }} %} {% link {{ info_path }} %}
{% assign screen_css_path = '/css' %} {% assign screen_css_path = '/css' %}
{% link {{ screen_css_path }}/screen.css %} {% link {{ screen_css_path }}/screen.css %}
CONTENT CONTENT
@ -195,7 +195,7 @@ class TestTagLink < TagUnitTest
--- ---
{% assign non_existent_path = 'non-existent-collection-item' %} {% assign non_existent_path = 'non-existent-collection-item' %}
{% link {{\ non_existent_path\ }} %} {% link {{ non_existent_path }} %}
CONTENT CONTENT
assert_raises ArgumentError do assert_raises ArgumentError do

View File

@ -3,7 +3,7 @@
require "helper" require "helper"
class TestUtils < JekyllUnitTest class TestUtils < JekyllUnitTest
context "The \`Utils.deep_merge_hashes\` method" do context "The `Utils.deep_merge_hashes` method" do
setup do setup do
clear_dest clear_dest
@site = fixture_site @site = fixture_site
@ -89,7 +89,7 @@ class TestUtils < JekyllUnitTest
end end
end end
context "The \`Utils.parse_date\` method" do context "The `Utils.parse_date` method" do
should "parse a properly formatted date" do should "parse a properly formatted date" do
assert_kind_of Time, Utils.parse_date("2014-08-02 14:43:06 PDT") assert_kind_of Time, Utils.parse_date("2014-08-02 14:43:06 PDT")
end end
@ -128,7 +128,7 @@ class TestUtils < JekyllUnitTest
end end
end end
context "The \`Utils.slugify\` method" do context "The `Utils.slugify` method" do
should "return nil if passed nil" do should "return nil if passed nil" do
assert_nil Utils.slugify(nil) assert_nil Utils.slugify(nil)
rescue NoMethodError rescue NoMethodError
@ -292,7 +292,7 @@ class TestUtils < JekyllUnitTest
end end
end end
context "The \`Utils.titleize_slug\` method" do context "The `Utils.titleize_slug` method" do
should "capitalize all words and not drop any words" do should "capitalize all words and not drop any words" do
assert_equal( assert_equal(
"This Is A Long Title With Mixed Capitalization", "This Is A Long Title With Mixed Capitalization",
@ -309,7 +309,7 @@ class TestUtils < JekyllUnitTest
end end
end end
context "The \`Utils.add_permalink_suffix\` method" do context "The `Utils.add_permalink_suffix` method" do
should "handle built-in permalink styles" do should "handle built-in permalink styles" do
assert_equal( assert_equal(
"/:basename/", "/:basename/",
@ -345,7 +345,7 @@ class TestUtils < JekyllUnitTest
end end
end end
context "The \`Utils.safe_glob\` method" do context "The `Utils.safe_glob` method" do
should "not apply pattern to the dir" do should "not apply pattern to the dir" do
dir = "test/safe_glob_test[" dir = "test/safe_glob_test["
assert_equal [], Dir.glob(dir + "/*") unless jruby? assert_equal [], Dir.glob(dir + "/*") unless jruby?
@ -383,7 +383,7 @@ class TestUtils < JekyllUnitTest
end end
end end
context "The \`Utils.has_yaml_header?\` method" do context "The `Utils.has_yaml_header?` method" do
should "accept files with YAML front matter" do should "accept files with YAML front matter" do
file = source_dir("_posts", "2008-10-18-foo-bar.markdown") file = source_dir("_posts", "2008-10-18-foo-bar.markdown")
assert_equal "---\n", File.open(file, "rb") { |f| f.read(4) } assert_equal "---\n", File.open(file, "rb") { |f| f.read(4) }
@ -401,7 +401,7 @@ class TestUtils < JekyllUnitTest
end end
end end
context "The \`Utils.merged_file_read_opts\` method" do context "The `Utils.merged_file_read_opts` method" do
should "ignore encoding if it's not there" do should "ignore encoding if it's not there" do
opts = Utils.merged_file_read_opts(nil, {}) opts = Utils.merged_file_read_opts(nil, {})
assert_nil opts["encoding"] assert_nil opts["encoding"]