diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..4e49af5 --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,31 @@ +name: RuboCop + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['3.3'] + + continue-on-error: ${{ matrix.channel != 'stable' }} + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + - name: Test with Rake + run: | + bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml index cc32da4..6385aa5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1 +1,13 @@ inherit_from: .rubocop_todo.yml + +require: + - rubocop-packaging + - rubocop-performance + - rubocop-rake + - rubocop-rspec + +AllCops: + TargetRubyVersion: 3.1 + NewCops: enable + DisplayStyleGuide: true + ExtraDetails: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a1616a6..bc3211d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,14 +1,13 @@ # This configuration was generated by -# `rubocop --auto-gen-config` -# on 2017-10-10 17:17:56 -0400 using RuboCop version 0.50.0. +# `rubocop --auto-gen-config --no-offense-counts --no-auto-gen-timestamp` +# using RuboCop version 1.66.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 # versions of RuboCop, may require this file to be generated again. -# Offense count: 17 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: leading, trailing Layout/DotPosition: Exclude: @@ -18,29 +17,25 @@ Layout/DotPosition: - 'spec/transformation_pipeline/transformations/aria_attributes_spec.rb' - 'spec/transformation_pipeline/transformations/data_attributes_spec.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/EmptyLineAfterMagicComment: +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLineAfterGuardClause: Exclude: - - 'inline_svg.gemspec' - - 'spec/cached_asset_file_spec.rb' + - 'lib/inline_svg.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLineAfterMagicComment: Exclude: - - 'spec/inline_svg_spec.rb' + - 'spec/cached_asset_file_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: around, only_before Layout/EmptyLinesAroundAccessModifier: Exclude: - 'lib/inline_svg/cached_asset_file.rb' -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines Layout/EmptyLinesAroundBlockBody: Exclude: @@ -49,69 +44,73 @@ Layout/EmptyLinesAroundBlockBody: - 'spec/io_resource_spec.rb' - 'spec/transformation_pipeline/transformations_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only Layout/EmptyLinesAroundClassBody: Exclude: - 'lib/inline_svg.rb' -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, IndentationWidth. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'lib/inline_svg/webpack_asset_finder.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: +Layout/FirstArrayElementIndentation: EnforcedStyle: consistent -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent -Layout/IndentHeredoc: +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: Exclude: - - 'spec/helpers/inline_svg_spec.rb' + - 'spec/transformation_pipeline/transformations_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. Layout/LeadingCommentSpace: Exclude: - 'Rakefile' -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented, indented_relative_to_receiver Layout/MultilineMethodCallIndentation: Exclude: - 'spec/transformation_pipeline/transformations/data_attributes_spec.rb' - 'spec/transformation_pipeline/transformations/style_attribute_spec.rb' + - 'spec/transformation_pipeline/transformations/view_box_spec.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: . # SupportedStyles: space, no_space Layout/SpaceAroundEqualsInParameterDefault: EnforcedStyle: no_space -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. +# SupportedStylesForExponentOperator: space, no_space +# SupportedStylesForRationalLiterals: space, no_space +Layout/SpaceAroundOperators: + Exclude: + - 'lib/inline_svg/webpack_asset_finder.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideBlockBraces: Exclude: - 'lib/inline_svg/transform_pipeline/transformations.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceInsideBrackets: - Exclude: - - 'lib/inline_svg.rb' - -# Offense count: 20 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideHashLiteralBraces: @@ -121,241 +120,409 @@ Layout/SpaceInsideHashLiteralBraces: - 'spec/transformation_pipeline/transformations/data_attributes_spec.rb' - 'spec/transformation_pipeline/transformations_spec.rb' -# Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, compact, no_space Layout/SpaceInsideParens: Exclude: - 'lib/inline_svg/transform_pipeline/transformations.rb' - 'spec/helpers/inline_svg_spec.rb' -# Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideReferenceBrackets: + Exclude: + - 'lib/inline_svg.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: Exclude: + - 'spec/helpers/inline_svg_spec.rb' - 'spec/io_resource_spec.rb' -# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperator: Exclude: - 'spec/io_resource_spec.rb' -# Offense count: 2 -Lint/ShadowingOuterLocalVariable: +# This cop supports safe autocorrection (--autocorrect). +Lint/LiteralInInterpolation: Exclude: - - 'lib/inline_svg/transform_pipeline/transformations/description.rb' - - 'lib/inline_svg/transform_pipeline/transformations/title.rb' + - 'spec/inline_svg_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Lint/UnneededSplatExpansion: +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowPercentLiteralArrayArgument. +Lint/RedundantSplatExpansion: Exclude: - 'lib/inline_svg.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/ShadowingOuterLocalVariable: + Exclude: + - 'lib/inline_svg/transform_pipeline/transformations/description.rb' + - 'lib/inline_svg/transform_pipeline/transformations/title.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: - 'lib/inline_svg/railtie.rb' - 'lib/inline_svg/transform_pipeline/transformations.rb' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. -Lint/UnusedMethodArgument: - Exclude: - - 'spec/inline_svg_spec.rb' - -# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. Lint/UselessAssignment: Exclude: - 'spec/cached_asset_file_spec.rb' - 'spec/transformation_pipeline/transformations/transformation_spec.rb' -# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: - Max: 17 - -# Offense count: 20 -# Configuration parameters: CountComments, ExcludedMethods. -Metrics/BlockLength: - Max: 169 + Max: 20 -# Offense count: 144 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 183 - -# Offense count: 3 -# Configuration parameters: CountComments. +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 14 + Max: 16 + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/inline_svg/action_view/helpers.rb' -# Offense count: 6 -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. # SupportedStyles: snake_case, normalcase, non_integer +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 Naming/VariableNumber: Exclude: - 'spec/cached_asset_file_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Performance/StringReplacement: +# This cop supports safe autocorrection (--autocorrect). +Packaging/RequireRelativeHardcodingLib: Exclude: - - 'lib/inline_svg/transform_pipeline/transformations/data_attributes.rb' + - 'spec/asset_file_spec.rb' + - 'spec/cached_asset_file_spec.rb' + - 'spec/finds_asset_paths_spec.rb' + - 'spec/id_generator_spec.rb' + - 'spec/inline_svg_spec.rb' + - 'spec/io_resource_spec.rb' + - 'spec/propshaft_asset_finder_spec.rb' + - 'spec/static_asset_finder_spec.rb' + - 'spec/webpack_asset_finder_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: always, conditionals -Style/AndOr: +# This cop supports safe autocorrection (--autocorrect). +Performance/CompareWithBlock: Exclude: - 'lib/inline_svg/cached_asset_file.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining -# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object -# FunctionalMethods: let, let!, subject, watch -# IgnoredMethods: lambda, proc, it -Style/BlockDelimiters: +# This cop supports safe autocorrection (--autocorrect). +Performance/ConstantRegexp: Exclude: - - 'lib/inline_svg/transform_pipeline/transformations.rb' + - 'spec/inline_svg_spec.rb' -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: braces, no_braces, context_dependent -Style/BracesAroundHashParameters: +# This cop supports unsafe autocorrection (--autocorrect-all). +Performance/MapCompact: Exclude: - 'lib/inline_svg/transform_pipeline/transformations.rb' + +# This cop supports safe autocorrection (--autocorrect). +Performance/RedundantSplitRegexpArgument: + Exclude: + - 'lib/inline_svg/transform_pipeline/transformations/size.rb' + +# This cop supports safe autocorrection (--autocorrect). +Performance/StringReplacement: + Exclude: + - 'lib/inline_svg/transform_pipeline/transformations/data_attributes.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. +RSpec/BeEmpty: + Exclude: + - 'spec/transformation_pipeline/transformations_spec.rb' + +# This cop supports safe autocorrection (--autocorrect). +RSpec/ContextMethod: + Exclude: + - 'spec/transformation_pipeline/transformations/transformation_spec.rb' + +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: - 'spec/helpers/inline_svg_spec.rb' - 'spec/inline_svg_spec.rb' - - 'spec/transformation_pipeline/transformations/data_attributes_spec.rb' + - 'spec/io_resource_spec.rb' + - 'spec/transformation_pipeline/transformations/aria_attributes_spec.rb' + - 'spec/transformation_pipeline/transformations/transformation_spec.rb' + - 'spec/transformation_pipeline/transformations_spec.rb' + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. +# SupportedStyles: described_class, explicit +RSpec/DescribedClass: + Enabled: false + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. +RSpec/EmptyExampleGroup: + Exclude: + - 'spec/io_resource_spec.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowConsecutiveOneLiners. +RSpec/EmptyLineAfterExample: + Exclude: + - 'spec/helpers/inline_svg_spec.rb' + +# This cop supports safe autocorrection (--autocorrect). +RSpec/EmptyLineAfterExampleGroup: + Exclude: + - 'spec/helpers/inline_svg_spec.rb' + - 'spec/io_resource_spec.rb' + +# This cop supports safe autocorrection (--autocorrect). +RSpec/EmptyLineAfterFinalLet: + Exclude: + - 'spec/helpers/inline_svg_spec.rb' + - 'spec/io_resource_spec.rb' + +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 32 + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: . +# SupportedStyles: implicit, each, example +RSpec/HookArgument: + EnforcedStyle: each + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit +RSpec/ImplicitSubject: + Exclude: + - 'spec/io_resource_spec.rb' + +# This cop supports safe autocorrection (--autocorrect). +RSpec/MatchArray: + Exclude: - 'spec/transformation_pipeline/transformations_spec.rb' -# Offense count: 6 +# Configuration parameters: . +# SupportedStyles: have_received, receive +RSpec/MessageSpies: + EnforcedStyle: receive + +RSpec/MultipleExpectations: + Max: 4 + +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only +RSpec/NamedSubject: + Exclude: + - 'spec/io_resource_spec.rb' + +# Configuration parameters: AllowedGroups. +RSpec/NestedGroups: + Max: 4 + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: not_to, to_not +RSpec/NotToNot: + Exclude: + - 'spec/helpers/inline_svg_spec.rb' + - 'spec/io_resource_spec.rb' + +RSpec/RepeatedExampleGroupDescription: + Exclude: + - 'spec/helpers/inline_svg_spec.rb' + +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Enabled: false + +RSpec/StubbedMock: + Exclude: + - 'spec/asset_file_spec.rb' + - 'spec/finds_asset_paths_spec.rb' + - 'spec/helpers/inline_svg_spec.rb' + - 'spec/propshaft_asset_finder_spec.rb' + - 'spec/static_asset_finder_spec.rb' + - 'spec/transformation_pipeline/transformations/aria_attributes_spec.rb' + - 'spec/webpack_asset_finder_spec.rb' + +# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. +RSpec/VerifiedDoubles: + Exclude: + - 'spec/finds_asset_paths_spec.rb' + - 'spec/helpers/inline_svg_spec.rb' + - 'spec/inline_svg_spec.rb' + - 'spec/propshaft_asset_finder_spec.rb' + - 'spec/static_asset_finder_spec.rb' + - 'spec/webpack_asset_finder_spec.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# AllowedMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'lib/inline_svg/transform_pipeline/transformations.rb' + - 'spec/helpers/inline_svg_spec.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowOnConstant, AllowOnSelfClass. Style/CaseEquality: Exclude: - 'lib/inline_svg/action_view/helpers.rb' - 'spec/io_resource_spec.rb' -# Offense count: 14 -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: + Enabled: false + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods, AllowedPatterns. +# AllowedMethods: ==, equal?, eql? +Style/ClassEqualityComparison: + Exclude: + - 'lib/inline_svg.rb' + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +Style/CollectionCompact: Exclude: - 'lib/inline_svg/transform_pipeline/transformations.rb' - - 'lib/inline_svg/transform_pipeline/transformations/aria_attributes.rb' - - 'lib/inline_svg/transform_pipeline/transformations/class_attribute.rb' - - 'lib/inline_svg/transform_pipeline/transformations/data_attributes.rb' - - 'lib/inline_svg/transform_pipeline/transformations/description.rb' - - 'lib/inline_svg/transform_pipeline/transformations/height.rb' - - 'lib/inline_svg/transform_pipeline/transformations/id_attribute.rb' - - 'lib/inline_svg/transform_pipeline/transformations/no_comment.rb' - - 'lib/inline_svg/transform_pipeline/transformations/preserve_aspect_ratio.rb' - - 'lib/inline_svg/transform_pipeline/transformations/size.rb' - - 'lib/inline_svg/transform_pipeline/transformations/style_attribute.rb' - - 'lib/inline_svg/transform_pipeline/transformations/title.rb' - - 'lib/inline_svg/transform_pipeline/transformations/transformation.rb' - - 'lib/inline_svg/transform_pipeline/transformations/width.rb' -# Offense count: 26 +# Configuration parameters: AllowedConstants. Style/Documentation: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/EachWithObject: Exclude: - 'lib/inline_svg/transform_pipeline/transformations.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AutoCorrectEncodingComment. -# SupportedStyles: when_needed, always, never -Style/Encoding: +# This cop supports safe autocorrection (--autocorrect). +Style/ExpandPathArguments: Exclude: - - 'inline_svg.gemspec' + - 'spec/cached_asset_file_spec.rb' + - 'spec/helpers/inline_svg_spec.rb' + - 'spec/io_resource_spec.rb' -# Offense count: 4 -# Configuration parameters: MinBodyLength. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: Exclude: - 'lib/inline_svg.rb' - 'lib/inline_svg/action_view/helpers.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent, either_consistent Style/HashSyntax: Exclude: - 'Rakefile' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. +# This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: + - 'lib/inline_svg.rb' - 'lib/inline_svg/static_asset_finder.rb' - 'lib/inline_svg/transform_pipeline/transformations/aria_attributes.rb' -# Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: InverseMethods, InverseBlocks. Style/InverseMethods: Exclude: - 'lib/inline_svg/transform_pipeline/transformations.rb' -# Offense count: 2 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/MapIntoArray: + Exclude: + - 'lib/inline_svg/transform_pipeline/transformations/aria_attributes.rb' + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict Style/MutableConstant: Exclude: - 'lib/inline_svg/asset_file.rb' - 'lib/inline_svg/version.rb' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: Whitelist. -# Whitelist: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowedMethods. +# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with Style/NestedParenthesizedCalls: Exclude: - 'spec/io_resource_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IncludeSemanticChanges. Style/NonNilCheck: Exclude: - 'lib/inline_svg/transform_pipeline/transformations.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Exclude: - - 'inline_svg.gemspec' - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedCompactTypes. # SupportedStyles: compact, exploded Style/RaiseArgs: - EnforcedStyle: compact + Exclude: + - 'lib/inline_svg.rb' + - 'lib/inline_svg/asset_file.rb' + - 'lib/inline_svg/cached_asset_file.rb' -# Offense count: 1 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Methods. +Style/RedundantArgument: + Exclude: + - 'lib/inline_svg/transform_pipeline/transformations/class_attribute.rb' + +# This cop supports safe autocorrection (--autocorrect). Style/RedundantBegin: Exclude: - 'lib/inline_svg.rb' -# Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantConstantBase: + Exclude: + - 'spec/propshaft_asset_finder_spec.rb' + - 'spec/static_asset_finder_spec.rb' + - 'spec/webpack_asset_finder_spec.rb' + +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpArgument: + Exclude: + - 'lib/inline_svg/transform_pipeline/transformations/data_attributes.rb' + - 'lib/inline_svg/transform_pipeline/transformations/size.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'lib/inline_svg/action_view/helpers.rb' + +# This cop supports safe autocorrection (--autocorrect). Style/RedundantSelf: Exclude: + - 'lib/inline_svg/transform_pipeline/transformations/aria_hidden.rb' + - 'lib/inline_svg/transform_pipeline/transformations/aria_hidden_attribute.rb' - 'lib/inline_svg/transform_pipeline/transformations/data_attributes.rb' - 'lib/inline_svg/transform_pipeline/transformations/height.rb' - 'lib/inline_svg/transform_pipeline/transformations/id_attribute.rb' @@ -364,58 +531,65 @@ Style/RedundantSelf: - 'lib/inline_svg/transform_pipeline/transformations/transformation.rb' - 'lib/inline_svg/transform_pipeline/transformations/width.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: Exclude: - 'spec/transformation_pipeline/transformations/transformation_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: use_perl_names, use_english_names -Style/SpecialGlobalVars: +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: Exclude: - - 'inline_svg.gemspec' + - 'lib/inline_svg/propshaft_asset_finder.rb' -# Offense count: 280 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'lib/inline_svg/id_generator.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. -# IgnoredMethods: respond_to, define_method +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. +# AllowedMethods: define_method Style/SymbolProc: Exclude: - 'lib/inline_svg/transform_pipeline/transformations/description.rb' - 'lib/inline_svg/transform_pipeline/transformations/no_comment.rb' - 'lib/inline_svg/transform_pipeline/transformations/title.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInArguments: +Style/TrailingCommaInArrayLiteral: Exclude: - 'spec/transformation_pipeline/transformations_spec.rb' -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInLiteral: +Style/TrailingCommaInHashLiteral: Exclude: - 'lib/inline_svg/transform_pipeline/transformations.rb' - 'spec/transformation_pipeline/transformations_spec.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Style/UnneededPercentQ: +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. +# AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +Style/TrivialAccessors: Exclude: - - 'inline_svg.gemspec' + - 'lib/inline_svg.rb' + +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 183 diff --git a/CHANGELOG.md b/CHANGELOG.md index ee5e30c..e8ebf19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased][unreleased] - Drop Support for Webpacker, Legacy Ruby (< 3.1), and Legacy Rails (< 7.0). [#163](https://github.com/jamesmartin/inline_svg/pull/163). Thanks, [@tagliala](https://github.com/tagliala) +- Reduce production gem size from 31K to 18K. [#165](https://github.com/jamesmartin/inline_svg/pull/165). Thanks, [@tagliala](https://github.com/tagliala) ## [1.10.0] - 2024-09-03 ### Added diff --git a/Gemfile b/Gemfile index a5f244f..f99cf70 100644 --- a/Gemfile +++ b/Gemfile @@ -7,4 +7,9 @@ gem "bundler" gem "pry" gem "rake" gem "rspec" -gem "rubocop" + +gem "rubocop", "1.66.1" +gem "rubocop-packaging", "0.5.2" +gem "rubocop-performance", "1.22.1" +gem "rubocop-rake", "0.6.0" +gem "rubocop-rspec", "3.0.5" diff --git a/README.md b/README.md index 6b0d12f..70f1b2f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Inline SVG -![Unit tests](https://github.com/jamesmartin/inline_svg/workflows/Ruby/badge.svg) -![Integration Tests](https://github.com/jamesmartin/inline_svg/workflows/Integration%20Tests/badge.svg) +[![Ruby](https://github.com/jamesmartin/inline_svg/actions/workflows/ruby.yml/badge.svg)](https://github.com/jamesmartin/inline_svg/actions/workflows/ruby.yml) +[![Integration Tests](https://github.com/jamesmartin/inline_svg/actions/workflows/integration_test.yml/badge.svg)](https://github.com/jamesmartin/inline_svg/actions/workflows/integration_test.yml) +[![RuboCop](https://github.com/jamesmartin/inline_svg/actions/workflows/rubocop.yml/badge.svg)](https://github.com/jamesmartin/inline_svg/actions/workflows/rubocop.yml) Styling a SVG document with CSS for use on the web is most reliably achieved by [adding classes to the document and diff --git a/inline_svg.gemspec b/inline_svg.gemspec index 70576c9..54a7b4a 100644 --- a/inline_svg.gemspec +++ b/inline_svg.gemspec @@ -1,5 +1,6 @@ -# coding: utf-8 -lib = File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'inline_svg/version' @@ -8,14 +9,13 @@ Gem::Specification.new do |spec| spec.version = InlineSvg::VERSION spec.authors = ["James Martin"] spec.email = ["inline_svg@jmrtn.com"] - spec.summary = %q{Embeds an SVG document, inline.} - spec.description = %q{Get an SVG into your view and then style it with CSS.} + spec.summary = 'Embeds an SVG document, inline.' + spec.description = 'Get an SVG into your view and then style it with CSS.' spec.homepage = "https://github.com/jamesmartin/inline_svg" spec.license = "MIT" - spec.files = `git ls-files`.split($/) + spec.files = Dir.glob('{CHANGELOG.md,LICENSE.txt,README.md,lib/**/*.rb}', File::FNM_DOTMATCH) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } - spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.metadata['rubygems_mfa_required'] = 'true'