From f7236dc769007a50f6cf3f12d5ed327efbfe5fc3 Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Sat, 26 Sep 2026 09:24:40 -0700 Subject: [PATCH] Enable Style/FrozenStringLiteralComment Remove the `Style/FrozenStringLiteralComment: Enabled: false` entry from .rubocop.yml so the cop runs with its default EnforcedStyle (always). Add `# frozen_string_literal: true` (via `rubocop -A --only Style/FrozenStringLiteralComment`, plus the blank line Layout/EmptyLineAfterMagicComment wants) to the 11 files that lacked it: Gemfile, code_ownership.gemspec, bin/codeownership, rakelib/*.rake, spec/spec_helper.rb, spec/support/application_fixtures.rb and spec/lib/code_ownership/cli_spec.rb. In bin/codeownership the pragma goes after the shebang and before the `# typed: strict` sigil. lib/, the Rakefile and extconf.rb already had it. No mutation fixes were needed. A static review of every string-mutating call in lib/, bin/, rakelib/, the gemspec, Gemfile and the specs found no mutation of a frozen literal. The one in-place append, `messages.last << "\n"` in ForFileOutputBuilder, always receives an interpolated (unfrozen) string, and the gem requires Ruby >= 3.3. The spec suite, the CLI, `rake pkg:ruby` and `gem build` also pass with the pragma, and the suite also passes under --enable-frozen-string-literal. --- .rubocop.yml | 4 ---- Gemfile | 2 ++ bin/codeownership | 1 + code_ownership.gemspec | 2 ++ rakelib/compile.rake | 2 ++ rakelib/env.rake | 2 ++ rakelib/helpers.rake | 2 ++ rakelib/pkg.rake | 2 ++ rakelib/spec.rake | 2 ++ spec/lib/code_ownership/cli_spec.rb | 2 ++ spec/spec_helper.rb | 2 ++ spec/support/application_fixtures.rb | 2 ++ 12 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3277532b..3f995f96 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -37,10 +37,6 @@ Lint/DuplicateBranch: Style/NegatedIf: Enabled: false -# Disabling for now until it's clearer why we want this -Style/FrozenStringLiteralComment: - Enabled: false - # It's nice to be able to read the condition first before reading the code within the condition Style/GuardClause: Enabled: false diff --git a/Gemfile b/Gemfile index 56582cfe..b932afa4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' gemspec diff --git a/bin/codeownership b/bin/codeownership index e711bda0..16a928f9 100755 --- a/bin/codeownership +++ b/bin/codeownership @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true # typed: strict require 'code_ownership' diff --git a/code_ownership.gemspec b/code_ownership.gemspec index c5330b7c..23a7f671 100644 --- a/code_ownership.gemspec +++ b/code_ownership.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative 'lib/code_ownership/version' Gem::Specification.new do |spec| diff --git a/rakelib/compile.rake b/rakelib/compile.rake index e8a3e114..e5ea612e 100644 --- a/rakelib/compile.rake +++ b/rakelib/compile.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rb_sys/extensiontask' RbSys::ExtensionTask.new('code_ownership', GEMSPEC) do |ext| diff --git a/rakelib/env.rake b/rakelib/env.rake index ae24bff5..fe30728e 100644 --- a/rakelib/env.rake +++ b/rakelib/env.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :env do desc 'Sets up environment variables "dev" builds' task :dev do diff --git a/rakelib/helpers.rake b/rakelib/helpers.rake index f9d11587..ca4e3d8a 100644 --- a/rakelib/helpers.rake +++ b/rakelib/helpers.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + REPO_FILES = Rake::FileList.new def dirglob(pattern) diff --git a/rakelib/pkg.rake b/rakelib/pkg.rake index 1363ac90..6d77abbf 100644 --- a/rakelib/pkg.rake +++ b/rakelib/pkg.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + CLOBBER.include('pkg/**/*.gem') CLEAN.include('tmp/pkg') CLEAN.include('tmp/pkg') diff --git a/rakelib/spec.rake b/rakelib/spec.rake index 69d303d3..737e97b1 100644 --- a/rakelib/spec.rake +++ b/rakelib/spec.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + CLEAN.include('.rspec_status') begin diff --git a/spec/lib/code_ownership/cli_spec.rb b/spec/lib/code_ownership/cli_spec.rb index e0c5b782..3fc6afde 100644 --- a/spec/lib/code_ownership/cli_spec.rb +++ b/spec/lib/code_ownership/cli_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe CodeOwnership::Cli do subject { CodeOwnership::Cli.run!(argv) } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f686b339..56e2b390 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/setup' require 'debug' require 'packwerk' diff --git a/spec/support/application_fixtures.rb b/spec/support/application_fixtures.rb index d574e332..89fabdab 100644 --- a/spec/support/application_fixtures.rb +++ b/spec/support/application_fixtures.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.shared_context 'application fixtures' do let(:codeowners_path) { Pathname.pwd.join('.github/CODEOWNERS') }