From cb2ca5132e2de8f7c49316b11dfb6e5d36fa61e0 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Tue, 25 Dec 2018 11:42:51 +0000 Subject: [PATCH] Remove redundant freeze calls * Rubocop meanwhile knows the singleton class problem. --- config/rubocop.yml | 4 ---- lib/mutant.rb | 4 ++-- lib/mutant/actor.rb | 2 +- lib/mutant/ast/meta/optarg.rb | 2 +- lib/mutant/ast/meta/send.rb | 2 +- lib/mutant/context.rb | 2 +- lib/mutant/diff.rb | 6 +++--- lib/mutant/env.rb | 2 +- lib/mutant/env/bootstrap.rb | 6 +++--- lib/mutant/expression.rb | 2 +- lib/mutant/integration/rspec.rb | 4 ++-- lib/mutant/matcher/config.rb | 10 +++++----- lib/mutant/matcher/method.rb | 4 ++-- lib/mutant/matcher/method/singleton.rb | 2 +- lib/mutant/mutation.rb | 8 ++++---- lib/mutant/mutator/node/argument.rb | 2 +- lib/mutant/mutator/node/literal/regex.rb | 2 +- lib/mutant/mutator/node/literal/symbol.rb | 2 +- lib/mutant/mutator/util/symbol.rb | 2 +- lib/mutant/reporter/cli/format.rb | 2 +- lib/mutant/reporter/cli/printer.rb | 2 +- .../reporter/cli/printer/mutation_progress_result.rb | 4 ++-- lib/mutant/reporter/cli/printer/status.rb | 4 ++-- lib/mutant/reporter/cli/printer/status_progressive.rb | 2 +- lib/mutant/reporter/cli/printer/subject_progress.rb | 2 +- lib/mutant/reporter/cli/printer/test_result.rb | 6 +++--- lib/mutant/repository.rb | 2 +- lib/mutant/subject/method/instance.rb | 2 +- lib/mutant/subject/method/singleton.rb | 2 +- lib/mutant/version.rb | 2 +- spec/support/corpus.rb | 10 +++++----- spec/support/warning.rb | 2 +- spec/unit/mutant/mutation_spec.rb | 2 +- 33 files changed, 54 insertions(+), 58 deletions(-) diff --git a/config/rubocop.yml b/config/rubocop.yml index c6c43335..88314af9 100644 --- a/config/rubocop.yml +++ b/config/rubocop.yml @@ -150,10 +150,6 @@ SignalException: Alias: EnforcedStyle: prefer_alias_method -# Teaching people to ignore singleton class is pointless -RedundantFreeze: - Enabled: false - # Do not waste my horizontal or vertical space IndentArray: Enabled: false diff --git a/lib/mutant.rb b/lib/mutant.rb index e5c36ae2..6ce976bb 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -29,10 +29,10 @@ Thread.abort_on_exception = true # # @api private module Mutant - EMPTY_STRING = ''.freeze + EMPTY_STRING = '' EMPTY_ARRAY = [].freeze EMPTY_HASH = {}.freeze - SCOPE_OPERATOR = '::'.freeze + SCOPE_OPERATOR = '::' # Test if CI is detected via environment # diff --git a/lib/mutant/actor.rb b/lib/mutant/actor.rb index 0b4affda..e5893c75 100644 --- a/lib/mutant/actor.rb +++ b/lib/mutant/actor.rb @@ -10,7 +10,7 @@ module Mutant # Undefined message payload Undefined = Class.new do - INSPECT = 'Mutant::Actor::Undefined'.freeze + INSPECT = 'Mutant::Actor::Undefined' # Object inspection # diff --git a/lib/mutant/ast/meta/optarg.rb b/lib/mutant/ast/meta/optarg.rb index 98b22113..278187c6 100644 --- a/lib/mutant/ast/meta/optarg.rb +++ b/lib/mutant/ast/meta/optarg.rb @@ -9,7 +9,7 @@ module Mutant class Optarg include NamedChildren, Concord.new(:node) - UNDERSCORE = '_'.freeze + UNDERSCORE = '_' children :name, :default_value diff --git a/lib/mutant/ast/meta/send.rb b/lib/mutant/ast/meta/send.rb index 5d79b853..6f4b40d4 100644 --- a/lib/mutant/ast/meta/send.rb +++ b/lib/mutant/ast/meta/send.rb @@ -14,7 +14,7 @@ module Mutant public :receiver, :selector INDEX_ASSIGNMENT_SELECTOR = :[]= - ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX = '='.freeze + ATTRIBUTE_ASSIGNMENT_SELECTOR_SUFFIX = '=' # Arguments of mutated node # diff --git a/lib/mutant/context.rb b/lib/mutant/context.rb index da8ac5bc..b9e2abbf 100644 --- a/lib/mutant/context.rb +++ b/lib/mutant/context.rb @@ -6,7 +6,7 @@ module Mutant include Adamantium::Flat, Concord::Public.new(:scope, :source_path) extend AST::Sexp - NAMESPACE_DELIMITER = '::'.freeze + NAMESPACE_DELIMITER = '::' # Return root node for mutation # diff --git a/lib/mutant/diff.rb b/lib/mutant/diff.rb index 81fef0ee..950e3b87 100644 --- a/lib/mutant/diff.rb +++ b/lib/mutant/diff.rb @@ -5,9 +5,9 @@ module Mutant class Diff include Adamantium::Flat, Concord.new(:old, :new) - ADDITION = '+'.freeze - DELETION = '-'.freeze - NEWLINE = "\n".freeze + ADDITION = '+' + DELETION = '-' + NEWLINE = "\n" # Unified source diff between old and new # diff --git a/lib/mutant/env.rb b/lib/mutant/env.rb index 8abb0a13..a3995c4d 100644 --- a/lib/mutant/env.rb +++ b/lib/mutant/env.rb @@ -16,7 +16,7 @@ module Mutant SEMANTICS_MESSAGE = "Fix your lib to follow normal ruby semantics!\n" \ - '{Module,Class}#name should return resolvable constant name as String or nil'.freeze + '{Module,Class}#name should return resolvable constant name as String or nil' # Kill mutation # diff --git a/lib/mutant/env/bootstrap.rb b/lib/mutant/env/bootstrap.rb index e6e37da4..5621ce38 100644 --- a/lib/mutant/env/bootstrap.rb +++ b/lib/mutant/env/bootstrap.rb @@ -8,13 +8,13 @@ module Mutant SEMANTICS_MESSAGE_FORMAT = "%s. Fix your lib to follow normal ruby semantics!\n" \ - '{Module,Class}#name should return resolvable constant name as String or nil'.freeze + '{Module,Class}#name should return resolvable constant name as String or nil' CLASS_NAME_RAISED_EXCEPTION = - '%s#name from: %s raised an error: %s'.freeze + '%s#name from: %s raised an error: %s' CLASS_NAME_TYPE_MISMATCH_FORMAT = - '%s#name from: %s returned %s'.freeze + '%s#name from: %s returned %s' private_constant(*constants(false)) diff --git a/lib/mutant/expression.rb b/lib/mutant/expression.rb index e77c2571..13aaae6e 100644 --- a/lib/mutant/expression.rb +++ b/lib/mutant/expression.rb @@ -8,7 +8,7 @@ module Mutant fragment = /[A-Za-z][A-Za-z\d_]*/.freeze SCOPE_NAME_PATTERN = /(?#{fragment}(?:#{SCOPE_OPERATOR}#{fragment})*)/.freeze - SCOPE_SYMBOL_PATTERN = '(?[.#])'.freeze + SCOPE_SYMBOL_PATTERN = '(?[.#])' private_constant(*constants(false)) diff --git a/lib/mutant/integration/rspec.rb b/lib/mutant/integration/rspec.rb index f946ac04..3fd7172e 100644 --- a/lib/mutant/integration/rspec.rb +++ b/lib/mutant/integration/rspec.rb @@ -25,10 +25,10 @@ module Mutant ALL_EXPRESSION = Expression::Namespace::Recursive.new(scope_name: nil) EXPRESSION_CANDIDATE = /\A([^ ]+)(?: )?/.freeze - LOCATION_DELIMITER = ':'.freeze + LOCATION_DELIMITER = ':' EXIT_SUCCESS = 0 CLI_OPTIONS = IceNine.deep_freeze(%w[spec --fail-fast]) - TEST_ID_FORMAT = 'rspec:%d:%s/%s'.freeze + TEST_ID_FORMAT = 'rspec:%d:%s/%s' private_constant(*constants(false)) diff --git a/lib/mutant/matcher/config.rb b/lib/mutant/matcher/config.rb index fbdff936..84ea668a 100644 --- a/lib/mutant/matcher/config.rb +++ b/lib/mutant/matcher/config.rb @@ -12,11 +12,11 @@ module Mutant :subject_filters ) - INSPECT_FORMAT = "#<#{self} %s>".freeze - ATTRIBUTE_DELIMITER = ' '.freeze - ATTRIBUTE_FORMAT = '%s: [%s]'.freeze - ENUM_DELIMITER = ','.freeze - EMPTY_ATTRIBUTES = 'empty'.freeze + INSPECT_FORMAT = "#<#{self} %s>" + ATTRIBUTE_DELIMITER = ' ' + ATTRIBUTE_FORMAT = '%s: [%s]' + ENUM_DELIMITER = ',' + EMPTY_ATTRIBUTES = 'empty' PRESENTATIONS = IceNine.deep_freeze( ignore_expressions: :syntax, match_expressions: :syntax, diff --git a/lib/mutant/matcher/method.rb b/lib/mutant/matcher/method.rb index 2b091205..e405879b 100644 --- a/lib/mutant/matcher/method.rb +++ b/lib/mutant/matcher/method.rb @@ -13,10 +13,10 @@ module Mutant BLACKLIST = %r{\A(kernel/|\(eval\)\z)}.freeze SOURCE_LOCATION_WARNING_FORMAT = - '%s does not have a valid source location, unable to emit subject'.freeze + '%s does not have a valid source location, unable to emit subject' CLOSURE_WARNING_FORMAT = - '%s is dynamically defined in a closure, unable to emit subject'.freeze + '%s is dynamically defined in a closure, unable to emit subject' # Matched subjects # diff --git a/lib/mutant/matcher/method/singleton.rb b/lib/mutant/matcher/method/singleton.rb index 446b1e74..5bcf2a20 100644 --- a/lib/mutant/matcher/method/singleton.rb +++ b/lib/mutant/matcher/method/singleton.rb @@ -21,7 +21,7 @@ module Mutant SUBJECT_CLASS = Subject::Method::Singleton RECEIVER_INDEX = 0 NAME_INDEX = 1 - RECEIVER_WARNING = 'Can only match :defs on :self or :const got %p unable to match'.freeze + RECEIVER_WARNING = 'Can only match :defs on :self or :const got %p unable to match' private diff --git a/lib/mutant/mutation.rb b/lib/mutant/mutation.rb index dab68ba1..edd2f597 100644 --- a/lib/mutant/mutation.rb +++ b/lib/mutant/mutation.rb @@ -6,7 +6,7 @@ module Mutant include AbstractType, Adamantium::Flat include Concord::Public.new(:subject, :node) - CODE_DELIMITER = "\0".freeze + CODE_DELIMITER = "\0" CODE_RANGE = (0..4).freeze # Identification string @@ -86,7 +86,7 @@ module Mutant # Evil mutation that should case mutations to fail tests class Evil < self - SYMBOL = 'evil'.freeze + SYMBOL = 'evil' TEST_PASS_SUCCESS = false end # Evil @@ -94,7 +94,7 @@ module Mutant # Neutral mutation that should not cause mutations to fail tests class Neutral < self - SYMBOL = 'neutral'.freeze + SYMBOL = 'neutral' TEST_PASS_SUCCESS = true end # Neutral @@ -102,7 +102,7 @@ module Mutant # Noop mutation, special case of neutral class Noop < Neutral - SYMBOL = 'noop'.freeze + SYMBOL = 'noop' TEST_PASS_SUCCESS = true end # Noop diff --git a/lib/mutant/mutator/node/argument.rb b/lib/mutant/mutator/node/argument.rb index 68ce8182..52f0db75 100644 --- a/lib/mutant/mutator/node/argument.rb +++ b/lib/mutant/mutator/node/argument.rb @@ -8,7 +8,7 @@ module Mutant class Argument < self handle(:arg, :kwarg) - UNDERSCORE = '_'.freeze + UNDERSCORE = '_' children :name diff --git a/lib/mutant/mutator/node/literal/regex.rb b/lib/mutant/mutator/node/literal/regex.rb index 5d0e4e9a..e220efa0 100644 --- a/lib/mutant/mutator/node/literal/regex.rb +++ b/lib/mutant/mutator/node/literal/regex.rb @@ -10,7 +10,7 @@ module Mutant handle(:regexp) # No input can ever be matched with this - NULL_REGEXP_SOURCE = 'nomatch\A'.freeze + NULL_REGEXP_SOURCE = 'nomatch\A' private diff --git a/lib/mutant/mutator/node/literal/symbol.rb b/lib/mutant/mutator/node/literal/symbol.rb index 0001685c..c0881566 100644 --- a/lib/mutant/mutator/node/literal/symbol.rb +++ b/lib/mutant/mutator/node/literal/symbol.rb @@ -11,7 +11,7 @@ module Mutant children :value - PREFIX = '__mutant__'.freeze + PREFIX = '__mutant__' private diff --git a/lib/mutant/mutator/util/symbol.rb b/lib/mutant/mutator/util/symbol.rb index 91b5fd88..6b81106e 100644 --- a/lib/mutant/mutator/util/symbol.rb +++ b/lib/mutant/mutator/util/symbol.rb @@ -7,7 +7,7 @@ module Mutant # Utility symbol mutator class Symbol < self - POSTFIX = '__mutant__'.freeze + POSTFIX = '__mutant__' private diff --git a/lib/mutant/reporter/cli/format.rb b/lib/mutant/reporter/cli/format.rb index 3ab9563d..3369e866 100644 --- a/lib/mutant/reporter/cli/format.rb +++ b/lib/mutant/reporter/cli/format.rb @@ -97,7 +97,7 @@ module Mutant class Framed < self include anima.add(:tput) - BUFFER_FLAGS = 'a+'.freeze + BUFFER_FLAGS = 'a+' REPORT_FREQUENCY = 20.0 REPORT_DELAY = 1 / REPORT_FREQUENCY diff --git a/lib/mutant/reporter/cli/printer.rb b/lib/mutant/reporter/cli/printer.rb index 9ef2c40d..4eded657 100644 --- a/lib/mutant/reporter/cli/printer.rb +++ b/lib/mutant/reporter/cli/printer.rb @@ -35,7 +35,7 @@ module Mutant delegate :success? - NL = "\n".freeze + NL = "\n" # Run printer # diff --git a/lib/mutant/reporter/cli/printer/mutation_progress_result.rb b/lib/mutant/reporter/cli/printer/mutation_progress_result.rb index 78f7f325..91c9f701 100644 --- a/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +++ b/lib/mutant/reporter/cli/printer/mutation_progress_result.rb @@ -6,8 +6,8 @@ module Mutant class Printer # Printer for mutation progress results class MutationProgressResult < self - SUCCESS = '.'.freeze - FAILURE = 'F'.freeze + SUCCESS = '.' + FAILURE = 'F' # Run printer # diff --git a/lib/mutant/reporter/cli/printer/status.rb b/lib/mutant/reporter/cli/printer/status.rb index 2e956195..7cce8a40 100644 --- a/lib/mutant/reporter/cli/printer/status.rb +++ b/lib/mutant/reporter/cli/printer/status.rb @@ -9,8 +9,8 @@ module Mutant delegate(:active_jobs, :payload) - ACTIVE_JOB_HEADER = 'Active Jobs:'.freeze - ACTIVE_JOB_FORMAT = '%d: %s'.freeze + ACTIVE_JOB_HEADER = 'Active Jobs:' + ACTIVE_JOB_FORMAT = '%d: %s' # Print progress for collector # diff --git a/lib/mutant/reporter/cli/printer/status_progressive.rb b/lib/mutant/reporter/cli/printer/status_progressive.rb index 06bea3bf..5769289a 100644 --- a/lib/mutant/reporter/cli/printer/status_progressive.rb +++ b/lib/mutant/reporter/cli/printer/status_progressive.rb @@ -6,7 +6,7 @@ module Mutant class Printer # Reporter for progressive output format on scheduler Status objects class StatusProgressive < self - FORMAT = '(%02d/%02d) %3d%% - killtime: %0.02fs runtime: %0.02fs overhead: %0.02fs'.freeze + FORMAT = '(%02d/%02d) %3d%% - killtime: %0.02fs runtime: %0.02fs overhead: %0.02fs' delegate( :coverage, diff --git a/lib/mutant/reporter/cli/printer/subject_progress.rb b/lib/mutant/reporter/cli/printer/subject_progress.rb index 25935f1e..0a664434 100644 --- a/lib/mutant/reporter/cli/printer/subject_progress.rb +++ b/lib/mutant/reporter/cli/printer/subject_progress.rb @@ -6,7 +6,7 @@ module Mutant class Printer # Reporter for subject progress class SubjectProgress < self - FORMAT = '(%02d/%02d) %3d%% - killtime: %0.02fs runtime: %0.02fs overhead: %0.02fs'.freeze + FORMAT = '(%02d/%02d) %3d%% - killtime: %0.02fs runtime: %0.02fs overhead: %0.02fs' delegate( :tests, diff --git a/lib/mutant/reporter/cli/printer/test_result.rb b/lib/mutant/reporter/cli/printer/test_result.rb index 12e178d0..d429dd19 100644 --- a/lib/mutant/reporter/cli/printer/test_result.rb +++ b/lib/mutant/reporter/cli/printer/test_result.rb @@ -9,9 +9,9 @@ module Mutant delegate :tests, :runtime - STATUS_FORMAT = '- %d @ runtime: %s'.freeze - OUTPUT_HEADER = 'Test Output:'.freeze - TEST_FORMAT = ' - %s'.freeze + STATUS_FORMAT = '- %d @ runtime: %s' + OUTPUT_HEADER = 'Test Output:' + TEST_FORMAT = ' - %s' # Run test result reporter # diff --git a/lib/mutant/repository.rb b/lib/mutant/repository.rb index a2316f01..7d97f3f1 100644 --- a/lib/mutant/repository.rb +++ b/lib/mutant/repository.rb @@ -24,7 +24,7 @@ module Mutant class Diff include Adamantium, Anima.new(:config, :from, :to) - HEAD = 'HEAD'.freeze + HEAD = 'HEAD' # Test if diff changes file at line range # diff --git a/lib/mutant/subject/method/instance.rb b/lib/mutant/subject/method/instance.rb index 4e066d22..2fc3011b 100644 --- a/lib/mutant/subject/method/instance.rb +++ b/lib/mutant/subject/method/instance.rb @@ -7,7 +7,7 @@ module Mutant class Instance < self NAME_INDEX = 0 - SYMBOL = '#'.freeze + SYMBOL = '#' # Prepare subject for mutation insertion # diff --git a/lib/mutant/subject/method/singleton.rb b/lib/mutant/subject/method/singleton.rb index 2ec8b49a..75ed29c2 100644 --- a/lib/mutant/subject/method/singleton.rb +++ b/lib/mutant/subject/method/singleton.rb @@ -7,7 +7,7 @@ module Mutant class Singleton < self NAME_INDEX = 1 - SYMBOL = '.'.freeze + SYMBOL = '.' # Prepare subject for mutation insertion # diff --git a/lib/mutant/version.rb b/lib/mutant/version.rb index b750b121..5a72f731 100644 --- a/lib/mutant/version.rb +++ b/lib/mutant/version.rb @@ -2,5 +2,5 @@ module Mutant # Current mutant version - VERSION = '0.8.23'.freeze + VERSION = '0.8.23' end # Mutant diff --git a/spec/support/corpus.rb b/spec/support/corpus.rb index 6046e2d7..80c802bd 100644 --- a/spec/support/corpus.rb +++ b/spec/support/corpus.rb @@ -14,7 +14,7 @@ module MutantSpec # rubocop:disable MethodLength module Corpus TMP = ROOT.join('tmp').freeze - EXCLUDE_GLOB_FORMAT = '{%s}'.freeze + EXCLUDE_GLOB_FORMAT = '{%s}' # Not in the docs. Number from chatting with their support. # 2 processors allocated per container, 4 processes works well. @@ -27,9 +27,9 @@ module MutantSpec class Project MUTEX = Mutex.new - MUTATION_GENERATION_MESSAGE = 'Total Mutations/Time/Parse-Errors: %s/%0.2fs - %0.2f/s'.freeze - START_MESSAGE = 'Starting - %s'.freeze - FINISH_MESSAGE = 'Mutations - %4i - %s'.freeze + MUTATION_GENERATION_MESSAGE = 'Total Mutations/Time/Parse-Errors: %s/%0.2fs - %0.2f/s' + START_MESSAGE = 'Starting - %s' + FINISH_MESSAGE = 'Mutations - %4i - %s' DEFAULT_MUTATION_COUNT = 0 @@ -272,7 +272,7 @@ module MutantSpec # Mapping of files which we expect to cause errors during mutation generation class ErrorWhitelist class UnnecessaryExpectation < StandardError - MESSAGE = 'Expected to encounter %s while mutating "%s"'.freeze + MESSAGE = 'Expected to encounter %s while mutating "%s"' def initialize(*error_info) super(MESSAGE % error_info) diff --git a/spec/support/warning.rb b/spec/support/warning.rb index a5119d1c..8147f513 100644 --- a/spec/support/warning.rb +++ b/spec/support/warning.rb @@ -14,7 +14,7 @@ module MutantSpec end class UnexpectedWarnings < StandardError - MSG = 'Unexpected warnings: %s'.freeze + MSG = 'Unexpected warnings: %s' def initialize(warnings) super(MSG % warnings.join("\n")) diff --git a/spec/unit/mutant/mutation_spec.rb b/spec/unit/mutant/mutation_spec.rb index 5101242e..dd431fae 100644 --- a/spec/unit/mutant/mutation_spec.rb +++ b/spec/unit/mutant/mutation_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Mutant::Mutation do let(:mutation_class) do Class.new(Mutant::Mutation) do - const_set(:SYMBOL, 'test'.freeze) + const_set(:SYMBOL, 'test') const_set(:TEST_PASS_SUCCESS, true) end end