Skip to content

Commit b9032b5

Browse files
HarlemSquirrelsds
authored andcommitted
Prepare for frozen string literals
- Add the magic comment to all files - Update Overcommit::HookContext::PreCommit to not use encode! - Set Rubocop target Ruby version to 2.3
1 parent f135f93 commit b9032b5

File tree

393 files changed

+789
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

393 files changed

+789
-27
lines changed

.rubocop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.2
2+
TargetRubyVersion: 2.3
33

44
Layout/ClosingParenthesisIndentation:
55
Enabled: false

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gemspec

bin/overcommit

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

34
# Check if Overcommit should invoke a Bundler context for loading gems
45
require 'yaml'

lib/overcommit.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/os'
24
require 'overcommit/constants'
35
require 'overcommit/exceptions'

lib/overcommit/command_splitter.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit
24
# Distributes a list of arguments over multiple invocations of a command.
35
#

lib/overcommit/configuration.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'digest'
24
require 'json'
35

lib/overcommit/configuration_validator.rb

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# rubocop:disable Metrics/ClassLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/LineLength
1+
# frozen_string_literal: true
2+
3+
# rubocop:disable Metrics/ClassLength, Metrics/MethodLength, Metrics/LineLength
24
module Overcommit
35
# Validates and normalizes a configuration.
46
class ConfigurationValidator
@@ -82,8 +84,8 @@ def check_hook_env(hash)
8284
end
8385

8486
if errors.any?
85-
@log.error errors.join("\n") if @log
86-
@log.newline if @log
87+
@log&.error errors.join("\n")
88+
@log&.newline
8789
raise Overcommit::Exceptions::ConfigurationError,
8890
'One or more hooks had an invalid `env` configuration option'
8991
end
@@ -107,8 +109,8 @@ def check_hook_name_format(hash)
107109
end
108110

109111
if errors.any?
110-
@log.error errors.join("\n") if @log
111-
@log.newline if @log
112+
@log&.error errors.join("\n")
113+
@log&.newline
112114
raise Overcommit::Exceptions::ConfigurationError,
113115
'One or more hooks had invalid names'
114116
end
@@ -154,8 +156,8 @@ def check_for_too_many_processors(config, hash)
154156
end
155157

156158
if errors.any?
157-
@log.error errors.join("\n") if @log
158-
@log.newline if @log
159+
@log&.error errors.join("\n")
160+
@log&.newline
159161
raise Overcommit::Exceptions::ConfigurationError,
160162
'One or more hooks had invalid `processor` value configured'
161163
end

lib/overcommit/constants.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Global application constants.
44
module Overcommit
55
HOME = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
6-
CONFIG_FILE_NAME = '.overcommit.yml'.freeze
6+
CONFIG_FILE_NAME = '.overcommit.yml'
77

88
HOOK_DIRECTORY = File.join(HOME, 'lib', 'overcommit', 'hook').freeze
99

10-
REPO_URL = 'https://github.com/brigade/overcommit'.freeze
11-
BUG_REPORT_URL = "#{REPO_URL}/issues".freeze
10+
REPO_URL = 'https://github.com/brigade/overcommit'
11+
BUG_REPORT_URL = "#{REPO_URL}/issues"
1212
end

lib/overcommit/exceptions.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Exceptions
24
# Raised when a {Configuration} could not be loaded from a file.
35
class ConfigurationError < StandardError; end

lib/overcommit/git_config.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/utils'
24

35
module Overcommit

lib/overcommit/git_repo.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'iniparse'
24

35
module Overcommit

lib/overcommit/git_version.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# Returns the version of the available git binary.
24
#
35
# This is intended to be used to conveniently execute code based on a specific

lib/overcommit/hook/base.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'forwardable'
24
require 'overcommit/message_processor'
35

lib/overcommit/hook/commit_msg/base.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'forwardable'
24

35
module Overcommit::Hook::CommitMsg

lib/overcommit/hook/commit_msg/capitalized_subject.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::CommitMsg
24
# Ensures commit message subject lines start with a capital letter.
35
class CapitalizedSubject < Base

lib/overcommit/hook/commit_msg/empty_message.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::CommitMsg
24
# Checks that the commit message is not empty
35
class EmptyMessage < Base

lib/overcommit/hook/commit_msg/gerrit_change_id.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::CommitMsg
24
# Ensures a Gerrit Change-Id line is included in the commit message.
35
#

lib/overcommit/hook/commit_msg/hard_tabs.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::CommitMsg
24
# Checks for hard tabs in commit messages.
35
class HardTabs < Base

lib/overcommit/hook/commit_msg/message_format.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::CommitMsg
24
# Ensures the commit message follows a specific format.
35
class MessageFormat < Base

lib/overcommit/hook/commit_msg/russian_novel.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::CommitMsg
24
# Checks for long commit messages (not good or bad--just fun to point out)
35
class RussianNovel < Base

lib/overcommit/hook/commit_msg/single_line_subject.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::CommitMsg
24
# Ensures commit message subject lines are followed by a blank line.
35
class SingleLineSubject < Base

lib/overcommit/hook/commit_msg/spell_check.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'tempfile'
24

35
module Overcommit::Hook::CommitMsg

lib/overcommit/hook/commit_msg/text_width.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::CommitMsg
24
# Ensures the number of columns the subject and commit message lines occupy is
35
# under the preferred limits.

lib/overcommit/hook/commit_msg/trailing_period.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::CommitMsg
24
# Ensures commit message subject lines do not have a trailing period
35
class TrailingPeriod < Base

lib/overcommit/hook/post_checkout/base.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'forwardable'
24

35
module Overcommit::Hook::PostCheckout

lib/overcommit/hook/post_checkout/bower_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/bower_install'
24

35
module Overcommit::Hook::PostCheckout

lib/overcommit/hook/post_checkout/bundle_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/bundle_install'
24

35
module Overcommit::Hook::PostCheckout

lib/overcommit/hook/post_checkout/composer_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/composer_install'
24

35
module Overcommit::Hook::PostCheckout

lib/overcommit/hook/post_checkout/index_tags.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/index_tags'
24

35
module Overcommit::Hook::PostCheckout

lib/overcommit/hook/post_checkout/npm_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/npm_install'
24

35
module Overcommit::Hook::PostCheckout

lib/overcommit/hook/post_checkout/submodule_status.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/submodule_status'
24

35
module Overcommit::Hook::PostCheckout

lib/overcommit/hook/post_checkout/yarn_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/yarn_install'
24

35
module Overcommit::Hook::PostCheckout

lib/overcommit/hook/post_commit/base.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'forwardable'
24

35
module Overcommit::Hook::PostCommit

lib/overcommit/hook/post_commit/bower_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/bower_install'
24

35
module Overcommit::Hook::PostCommit

lib/overcommit/hook/post_commit/bundle_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/bundle_install'
24

35
module Overcommit::Hook::PostCommit

lib/overcommit/hook/post_commit/commitplease.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::PostCommit
24
# Check that a commit message conforms to a certain style
35
#

lib/overcommit/hook/post_commit/composer_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/composer_install'
24

35
module Overcommit::Hook::PostCommit

lib/overcommit/hook/post_commit/git_guilt.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::PostCommit
24
# Calculates the change in blame since the last revision.
35
#

lib/overcommit/hook/post_commit/index_tags.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/index_tags'
24

35
module Overcommit::Hook::PostCommit

lib/overcommit/hook/post_commit/npm_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/npm_install'
24

35
module Overcommit::Hook::PostCommit

lib/overcommit/hook/post_commit/submodule_status.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/submodule_status'
24

35
module Overcommit::Hook::PostCommit

lib/overcommit/hook/post_commit/yarn_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/yarn_install'
24

35
module Overcommit::Hook::PostCommit

lib/overcommit/hook/post_merge/base.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'forwardable'
24

35
module Overcommit::Hook::PostMerge

lib/overcommit/hook/post_merge/bower_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/bower_install'
24

35
module Overcommit::Hook::PostMerge

lib/overcommit/hook/post_merge/bundle_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/bundle_install'
24

35
module Overcommit::Hook::PostMerge

lib/overcommit/hook/post_merge/composer_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/composer_install'
24

35
module Overcommit::Hook::PostMerge

lib/overcommit/hook/post_merge/index_tags.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/index_tags'
24

35
module Overcommit::Hook::PostMerge

lib/overcommit/hook/post_merge/npm_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/npm_install'
24

35
module Overcommit::Hook::PostMerge

lib/overcommit/hook/post_merge/submodule_status.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/submodule_status'
24

35
module Overcommit::Hook::PostMerge

lib/overcommit/hook/post_merge/yarn_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/yarn_install'
24

35
module Overcommit::Hook::PostMerge

lib/overcommit/hook/post_rewrite/base.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'forwardable'
24

35
module Overcommit::Hook::PostRewrite

lib/overcommit/hook/post_rewrite/bower_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/bower_install'
24

35
module Overcommit::Hook::PostRewrite

lib/overcommit/hook/post_rewrite/bundle_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/bundle_install'
24

35
module Overcommit::Hook::PostRewrite

lib/overcommit/hook/post_rewrite/composer_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/composer_install'
24

35
module Overcommit::Hook::PostRewrite

lib/overcommit/hook/post_rewrite/index_tags.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/index_tags'
24

35
module Overcommit::Hook::PostRewrite

lib/overcommit/hook/post_rewrite/npm_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/npm_install'
24

35
module Overcommit::Hook::PostRewrite

lib/overcommit/hook/post_rewrite/submodule_status.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/submodule_status'
24

35
module Overcommit::Hook::PostRewrite

lib/overcommit/hook/post_rewrite/yarn_install.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'overcommit/hook/shared/yarn_install'
24

35
module Overcommit::Hook::PostRewrite

lib/overcommit/hook/pre_commit/author_email.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Overcommit::Hook::PreCommit
24
# Checks the format of an author's email address.
35
class AuthorEmail < Base

0 commit comments

Comments
 (0)