diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43a21e9cb..a41403ed2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: ruby-mutant: name: Mutation coverage runs-on: ${{ matrix.os }} - timeout-minutes: 5 + timeout-minutes: 30 strategy: fail-fast: false matrix: @@ -47,7 +47,7 @@ jobs: - run: | gem install bundler bundle install - - run: bundle exec mutant --since HEAD~1 --zombie -- 'Mutant*' + - run: ./mutant.sh ruby-integration-minitest: name: Integration Minitest runs-on: ${{ matrix.os }} diff --git a/lib/mutant/ast.rb b/lib/mutant/ast.rb index b5b58e534..477b40e47 100644 --- a/lib/mutant/ast.rb +++ b/lib/mutant/ast.rb @@ -27,15 +27,6 @@ def self.find_last_path(node, &predicate) path end - # Walk all ast nodes keeping track of path - # - # @param [Parser::AST::Node] root - # @param [Array] stack - # - # @yield [Parser::AST::Node] - # all nodes visited recursively including root - # - # @return [undefined] def self.walk(node, stack, &block) block.call(node, stack) node.children.grep(::Parser::AST::Node) do |child| diff --git a/lib/mutant/ast/meta/send.rb b/lib/mutant/ast/meta/send.rb index 6f4b40d41..41a2c9e08 100644 --- a/lib/mutant/ast/meta/send.rb +++ b/lib/mutant/ast/meta/send.rb @@ -56,16 +56,10 @@ def receiver_possible_top_level_const? private - # Test if node is `proc { ... }` - # - # @return [Boolean] def naked_proc? !receiver && selector.equal?(:proc) end - # Test if node is `Proc.new { ... }` - # - # @return [Boolean] def proc_new? receiver && selector.equal?(:new) && diff --git a/lib/mutant/bootstrap.rb b/lib/mutant/bootstrap.rb index 7d89348a2..1fd02da5d 100644 --- a/lib/mutant/bootstrap.rb +++ b/lib/mutant/bootstrap.rb @@ -49,9 +49,6 @@ def self.apply(world, config) end # rubocop:enable Metrics/MethodLength - # Infect environment - # - # @return [undefined] def self.infect(env) config, world = env.config, env.world @@ -60,12 +57,6 @@ def self.infect(env) end private_class_method :infect - # Matchable scopes - # - # @param [World] world - # @param [Config] config - # - # @return [Array] def self.matchable_scopes(world, config) scopes = world.object_space.each_object(Module).each_with_object([]) do |scope, aggregate| expression = expression(config.reporter, config.expression_parser, scope) || next @@ -76,15 +67,6 @@ def self.matchable_scopes(world, config) end private_class_method :matchable_scopes - # Scope name from scoping object - # - # @param [Class, Module] scope - # - # @return [String] - # if scope has a name and does not raise exceptions obtaining it - # - # @return [nil] - # otherwise def self.scope_name(reporter, scope) scope.name rescue => exception @@ -99,20 +81,7 @@ def self.scope_name(reporter, scope) end private_class_method :scope_name - # Try to turn scope into expression - # - # @param [Expression::Parser] expression_parser - # @param [Class, Module] scope - # - # @return [Expression] - # if scope can be represented in an expression - # - # @return [nil] - # otherwise - # # rubocop:disable Metrics/MethodLength - # - # ignore :reek:LongParameterList def self.expression(reporter, expression_parser, scope) name = scope_name(reporter, scope) or return @@ -132,11 +101,6 @@ def self.expression(reporter, expression_parser, scope) private_class_method :expression # rubocop:enable Metrics/MethodLength - # Write a semantics warning - # - # @return [undefined] - # - # ignore :reek:LongParameterList def self.semantics_warning(reporter, format, options) reporter.warn(SEMANTICS_MESSAGE_FORMAT % { message: format % options }) end diff --git a/lib/mutant/cli.rb b/lib/mutant/cli.rb index 7679c78fd..1869c4ca2 100644 --- a/lib/mutant/cli.rb +++ b/lib/mutant/cli.rb @@ -88,23 +88,12 @@ def parse(arguments) private - # Parse matchers - # - # @param [Array] expressions - # - # @return [undefined] def parse_match_expressions(expressions) expressions.each do |expression| add_matcher(:match_expressions, config.expression_parser.apply(expression).from_right) end end - # Add environmental options - # - # @param [Object] opts - # - # @return [undefined] - # # rubocop:disable Metrics/MethodLength def add_environment_options(opts) opts.separator('Environment:') @@ -121,12 +110,8 @@ def add_environment_options(opts) with(jobs: Integer(number)) end end + # rubocop:enable Metrics/MethodLength - # Add mutation options - # - # @param [OptionParser] opts - # - # @return [undefined] def add_mutation_options(opts) opts.separator(nil) opts.separator('Options:') @@ -136,11 +121,7 @@ def add_mutation_options(opts) end end - # Add filter options - # - # @param [OptionParser] opts - # - # @return [undefined] + # rubocop:disable Metrics/MethodLength def add_filter_options(opts) opts.on('--ignore-subject EXPRESSION', 'Ignore subjects that match EXPRESSION as prefix') do |pattern| add_matcher(:ignore_expressions, config.expression_parser.apply(pattern).from_right) @@ -154,12 +135,9 @@ def add_filter_options(opts) ) end end + # rubocop:enable Metrics/MethodLength - # Add debug options - # - # @param [OptionParser] opts - # - # @return [undefined] + # rubocop:disable Metrics/MethodLength def add_debug_options(opts) opts.on('--fail-fast', 'Fail fast') do with(fail_fast: true) @@ -173,38 +151,16 @@ def add_debug_options(opts) world.kernel.exit end end + # rubocop:enable Metrics/MethodLength - # With configuration - # - # @param [Hash] attributes - # - # @return [undefined] def with(attributes) @config = config.with(attributes) end - # Add configuration - # - # @param [Symbol] attribute - # the attribute to add to - # - # @param [Object] value - # the value to add - # - # @return [undefined] def add(attribute, value) with(attribute => config.public_send(attribute) + [value]) end - # Add matcher configuration - # - # @param [Symbol] attribute - # the attribute to add to - # - # @param [Object] value - # the value to add - # - # @return [undefined] def add_matcher(attribute, value) with(matcher: config.matcher.add(attribute, value)) end diff --git a/lib/mutant/color.rb b/lib/mutant/color.rb index 25e76a5c7..85336751d 100644 --- a/lib/mutant/color.rb +++ b/lib/mutant/color.rb @@ -28,9 +28,6 @@ def format(text) private - # Initialize null color - # - # @return [undefined] def initialize; end end.new diff --git a/lib/mutant/config.rb b/lib/mutant/config.rb index 4359cf65f..62436ce66 100644 --- a/lib/mutant/config.rb +++ b/lib/mutant/config.rb @@ -126,14 +126,6 @@ def self.load_config_file(world, config) end end - # Load contents of file - # - # @param [Pathname] path - # - # @return [Config] - # - # @raise [Either Object}>] - # in case of config file error def self.load_contents(path) Transform::Named .new(path.to_s, TRANSFORM) diff --git a/lib/mutant/context.rb b/lib/mutant/context.rb index b9e2abbf0..f3a6f52ae 100644 --- a/lib/mutant/context.rb +++ b/lib/mutant/context.rb @@ -81,9 +81,6 @@ def match_expressions private - # Nesting of names in scope - # - # @return [Array] def name_nesting scope.name.split(NAMESPACE_DELIMITER) end diff --git a/lib/mutant/diff.rb b/lib/mutant/diff.rb index 950e3b876..22719d5e7 100644 --- a/lib/mutant/diff.rb +++ b/lib/mutant/diff.rb @@ -58,25 +58,16 @@ def self.lines(source) private - # Diffs between old and new - # - # @return [Array] def diffs ::Diff::LCS.diff(old, new) end - # Raw diff-lcs hunks - # - # @return [Array] def hunks diffs.map do |diff| ::Diff::LCS::Hunk.new(old.map(&:dup), new, diff, max_length, 0) end end - # Minimized hunk - # - # @return Diff::LCS::Hunk def minimized_hunk head, *tail = hunks @@ -86,18 +77,10 @@ def minimized_hunk end end - # Max length of source line in new and old - # - # @return [Integer] def max_length [old, new].map(&:length).max end - # Colorized a unified diff line - # - # @param [String] line - # - # @return [String] def self.colorize_line(line) case line[0] when ADDITION diff --git a/lib/mutant/env.rb b/lib/mutant/env.rb index 3ffb767a2..5569510cb 100644 --- a/lib/mutant/env.rb +++ b/lib/mutant/env.rb @@ -126,12 +126,6 @@ def test_subject_ratio private - # Kill mutation under isolation with integration - # - # @param [Mutation] mutation - # @param [Array] test - # - # @return [Result::Isolation] def run_mutation_tests(mutation, tests) config.isolation.call do result = mutation.insert(world.kernel) diff --git a/lib/mutant/expression/method.rb b/lib/mutant/expression/method.rb index bcc46a740..8a35489f9 100644 --- a/lib/mutant/expression/method.rb +++ b/lib/mutant/expression/method.rb @@ -46,9 +46,6 @@ def matcher private - # Scope object - # - # @return [Class, Method] def scope Object.const_get(scope_name) end diff --git a/lib/mutant/expression/methods.rb b/lib/mutant/expression/methods.rb index 05489fd6a..0e10af420 100644 --- a/lib/mutant/expression/methods.rb +++ b/lib/mutant/expression/methods.rb @@ -50,9 +50,6 @@ def match_length(expression) private - # Scope object - # - # @return [Class, Method] def scope Object.const_get(scope_name) end diff --git a/lib/mutant/expression/parser.rb b/lib/mutant/expression/parser.rb index 9935c6a20..2b8f40c0a 100644 --- a/lib/mutant/expression/parser.rb +++ b/lib/mutant/expression/parser.rb @@ -28,12 +28,6 @@ def apply(input) private - # Expressions parsed from input - # - # @param [String] input - # - # @return [Array] - # if expressions can be parsed from input def expressions(input) types.each_with_object([]) do |type, aggregate| expression = type.try_parse(input) and aggregate << expression diff --git a/lib/mutant/integration.rb b/lib/mutant/integration.rb index 0102eaf09..c3121ba48 100644 --- a/lib/mutant/integration.rb +++ b/lib/mutant/integration.rb @@ -32,14 +32,6 @@ def self.setup(env) .fmap { |klass| klass.new(env.config).setup } end - # Attempt to require integration - # - # @param env [Bootstrap] - # - # @return [Either] - # - # @api private - # # rubocop:disable Style/MultilineBlockChain def self.attempt_require(env) integration_name = env.config.integration @@ -56,13 +48,6 @@ def self.attempt_require(env) private_class_method :attempt_require # rubocop:enable Style/MultilineBlockChain - # Attempt const get - # - # @param env [Boostrap] - # - # @return [Either>] - # - # @api private def self.attempt_const_get(env) integration_name = env.config.integration constant_name = integration_name.capitalize @@ -98,9 +83,6 @@ def setup private - # Expression parser - # - # @return [Expression::Parser] def expression_parser config.expression_parser end diff --git a/lib/mutant/integration/minitest.rb b/lib/mutant/integration/minitest.rb index 2b3cc2a6b..f7befbe21 100644 --- a/lib/mutant/integration/minitest.rb +++ b/lib/mutant/integration/minitest.rb @@ -115,9 +115,6 @@ def all_tests private - # The index of all tests to runnable test cases - # - # @return [Hash] def all_tests_index all_test_cases.each_with_object({}) do |test_case, index| index[construct_test(test_case)] = test_case diff --git a/lib/mutant/integration/rspec.rb b/lib/mutant/integration/rspec.rb index 7519aa20b..d7377daf9 100644 --- a/lib/mutant/integration/rspec.rb +++ b/lib/mutant/integration/rspec.rb @@ -80,9 +80,6 @@ def all_tests private - # Index of available tests - # - # @return [Hash Array] def present_attributes to_h.reject { |_key, value| value.empty? }.keys end - # Formatted attributes - # - # @return [String] def inspect_attributes attributes = present_attributes .map(&method(:format_attribute)) @@ -62,11 +56,6 @@ def inspect_attributes attributes.empty? ? EMPTY_ATTRIBUTES : attributes end - # Format attribute - # - # @param [Symbol] attribute_name - # - # @return [String] def format_attribute(attribute_name) ATTRIBUTE_FORMAT % [ diff --git a/lib/mutant/matcher/method.rb b/lib/mutant/matcher/method.rb index 814001209..d3573938e 100644 --- a/lib/mutant/matcher/method.rb +++ b/lib/mutant/matcher/method.rb @@ -49,9 +49,6 @@ def call private - # Test if method should be skipped - # - # @return [Truthy] def skip? location = source_location if location.nil? || BLACKLIST.include?(location.first) @@ -61,56 +58,31 @@ def skip? end end - # Target method name - # - # @return [String] def method_name target_method.name end - # Target context - # - # @return [Context] def context Context.new(scope, source_path) end - # Root source node - # - # @return [Parser::AST::Node] def ast env.parser.call(source_path) end - # Path to source - # - # @return [Pathname] def source_path env.world.pathname.new(source_location.first) end memoize :source_path - # Source file line - # - # @return [Integer] def source_line source_location.last end - # Full source location - # - # @return [Array{String,Integer}] def source_location target_method.source_location end - # Matched subject - # - # @return [Subject] - # if there is a matched node - # - # @return [nil] - # otherwise def subject node = matched_node_path.last || return @@ -122,9 +94,6 @@ def subject end memoize :subject - # Matched node path - # - # @return [Array] def matched_node_path AST.find_last_path(ast, &method(:match?)) end diff --git a/lib/mutant/matcher/method/instance.rb b/lib/mutant/matcher/method/instance.rb index d646113b1..65c18f8c7 100644 --- a/lib/mutant/matcher/method/instance.rb +++ b/lib/mutant/matcher/method/instance.rb @@ -33,11 +33,6 @@ class Evaluator < Evaluator private - # Check if node is matched - # - # @param [Parser::AST::Node] node - # - # @return [Boolean] def match?(node) n_def?(node) && node.location.line.equal?(source_line) && @@ -50,9 +45,6 @@ class Memoized < self private - # Source location - # - # @return [Array{String,Integer}] def source_location scope .unmemoized_instance_method(method_name) diff --git a/lib/mutant/matcher/method/singleton.rb b/lib/mutant/matcher/method/singleton.rb index 5bcf2a206..4b1515014 100644 --- a/lib/mutant/matcher/method/singleton.rb +++ b/lib/mutant/matcher/method/singleton.rb @@ -25,20 +25,10 @@ class Evaluator < Evaluator private - # Test for node match - # - # @param [Parser::AST::Node] node - # - # @return [Boolean] def match?(node) n_defs?(node) && line?(node) && name?(node) && receiver?(node) end - # Test for line match - # - # @param [Parser::AST::Node] node - # - # @return [Boolean] def line?(node) node .location @@ -46,20 +36,10 @@ def line?(node) .equal?(source_line) end - # Test for name match - # - # @param [Parser::AST::Node] node - # - # @return [Boolean] def name?(node) node.children.fetch(NAME_INDEX).equal?(method_name) end - # Test for receiver match - # - # @param [Parser::AST::Node] node - # - # @return [Boolean] def receiver?(node) receiver = node.children.fetch(RECEIVER_INDEX) case receiver.type @@ -73,11 +53,6 @@ def receiver?(node) end end - # Test if receiver name matches context - # - # @param [Parser::AST::Node] node - # - # @return [Boolean] def receiver_name?(node) name = node.children.fetch(NAME_INDEX) name.to_s.eql?(context.unqualified_name) diff --git a/lib/mutant/matcher/methods.rb b/lib/mutant/matcher/methods.rb index d18239b3a..1a4636853 100644 --- a/lib/mutant/matcher/methods.rb +++ b/lib/mutant/matcher/methods.rb @@ -27,16 +27,10 @@ def call(env) private - # method matcher class - # - # @return [Class:Matcher::Method] def matcher self.class::MATCHER end - # Available methods scope - # - # @return [Enumerable] def methods candidate_names.each_with_object([]) do |name, methods| method = access(name) @@ -45,9 +39,6 @@ def methods end memoize :methods - # Candidate method names on target scope - # - # @return [Enumerable] def candidate_names CANDIDATE_NAMES .map(&candidate_scope.method(:public_send)) @@ -55,10 +46,8 @@ def candidate_names .sort end - # Candidate scope - # - # @return [Class, Module] abstract_method :candidate_scope + private :candidate_scope # Matcher for singleton methods class Singleton < self @@ -66,18 +55,10 @@ class Singleton < self private - # Method object on scope - # - # @param [Symbol] method_name - # - # @return [Method] def access(method_name) scope.method(method_name) end - # Candidate scope - # - # @return [Class] def candidate_scope scope.singleton_class end @@ -91,18 +72,10 @@ class Instance < self private - # Method object on scope - # - # @param [Symbol] method_name - # - # @return [UnboundMethod] def access(method_name) scope.instance_method(method_name) end - # Candidate scope - # - # @return [Class, Module] def candidate_scope scope end diff --git a/lib/mutant/matcher/namespace.rb b/lib/mutant/matcher/namespace.rb index 513b90546..347e3dba0 100644 --- a/lib/mutant/matcher/namespace.rb +++ b/lib/mutant/matcher/namespace.rb @@ -19,22 +19,12 @@ def call(env) private - # The matched scopes - # - # @param [Env] env - # - # @return [Enumerable] def matched_scopes(env) env .matchable_scopes .select(&method(:match?)) end - # Test scope if matches expression - # - # @param [Scope] scope - # - # @return [Boolean] def match?(scope) expression.prefix?(scope.expression) end diff --git a/lib/mutant/matcher/scope.rb b/lib/mutant/matcher/scope.rb index b981dff78..e509da5f4 100644 --- a/lib/mutant/matcher/scope.rb +++ b/lib/mutant/matcher/scope.rb @@ -29,9 +29,6 @@ def call(env) private - # Effective matchers - # - # @return [Enumerable] def effective_matchers MATCHERS.map { |matcher| matcher.new(scope) } end diff --git a/lib/mutant/meta/example/dsl.rb b/lib/mutant/meta/example/dsl.rb index ed3b93b22..8897d7697 100644 --- a/lib/mutant/meta/example/dsl.rb +++ b/lib/mutant/meta/example/dsl.rb @@ -49,21 +49,11 @@ def example private - # Set original source - # - # @param [String,Parser::AST::Node] input - # - # @return [undefined] def source(input) fail 'source already defined' if @node @node = node(input) end - # Add expected mutation - # - # @param [String,Parser::AST::Node] input - # - # @return [undefined] def mutation(input) node = node(input) if @expected.include?(node) @@ -72,22 +62,11 @@ def mutation(input) @expected << node end - # Add singleton mutations - # - # @return [undefined] def singleton_mutations mutation('nil') mutation('self') end - # Helper method to coerce input to node - # - # @param [String,Parser::AST::Node] input - # - # @return [Parser::AST::Node] - # - # @raise [RuntimeError] - # in case input cannot be coerced def node(input) case input when String diff --git a/lib/mutant/meta/example/verification.rb b/lib/mutant/meta/example/verification.rb index b2d1db8d3..621aaf62a 100644 --- a/lib/mutant/meta/example/verification.rb +++ b/lib/mutant/meta/example/verification.rb @@ -35,9 +35,6 @@ def error_report private - # Unexpected mutations - # - # @return [Array] def unexpected mutations.reject do |mutation| example.expected.include?(mutation.node) @@ -45,9 +42,6 @@ def unexpected end memoize :unexpected - # Missing mutations - # - # @return [Array] def missing (example.expected - mutations.map(&:node)).map do |node| Mutation::Evil.new(self, node) @@ -55,9 +49,6 @@ def missing end memoize :missing - # Mutations that generated invalid syntax - # - # @return [Enumerable] def invalid_syntax mutations.reject do |mutation| ::Parser::CurrentRuby.parse(mutation.source) @@ -66,19 +57,11 @@ def invalid_syntax end memoize :invalid_syntax - # Mutations with no diff to original - # - # @return [Enumerable] def no_diffs mutations.select { |mutation| mutation.source.eql?(example.source) } end memoize :no_diffs - # Mutation report - # - # @param [Array] mutations - # - # @return [Array] def format_mutations(mutations) mutations.map do |mutation| { @@ -88,9 +71,6 @@ def format_mutations(mutations) end end - # No diff mutation report - # - # @return [Array, nil] def no_diff_report no_diffs.map do |mutation| { diff --git a/lib/mutant/minitest/coverage.rb b/lib/mutant/minitest/coverage.rb index 2ff8cf9bf..7acec17b4 100644 --- a/lib/mutant/minitest/coverage.rb +++ b/lib/mutant/minitest/coverage.rb @@ -40,11 +40,6 @@ def resolve_cover_expression private - # Attempt to resolve superclass cover expressio - # - # @return [String, nil] - # - # @api private def try_superclass_cover_expression return if superclass.equal?(::Minitest::Runnable) diff --git a/lib/mutant/mutation.rb b/lib/mutant/mutation.rb index 615419151..df185920c 100644 --- a/lib/mutant/mutation.rb +++ b/lib/mutant/mutation.rb @@ -74,9 +74,6 @@ def insert(kernel) private - # SHA1 sum of source and subject identification - # - # @return [String] def sha1 Digest::SHA1.hexdigest(subject.identification + CODE_DELIMITER + source) end diff --git a/lib/mutant/mutator.rb b/lib/mutant/mutator.rb index 645f57186..a03f33df7 100644 --- a/lib/mutant/mutator.rb +++ b/lib/mutant/mutator.rb @@ -18,9 +18,6 @@ def self.mutate(node, parent = nil) self::REGISTRY.lookup(node.type).call(node, parent) end - # Register node class handler - # - # @return [undefined] def self.handle(*types) types.each do |type| self::REGISTRY.register(type, self) @@ -35,13 +32,6 @@ def self.handle(*types) private - # Initialize object - # - # @param [Object] input - # @param [Object] parent - # @param [#call(node)] block - # - # @return [undefined] def initialize(_input, _parent = nil) super @@ -50,41 +40,23 @@ def initialize(_input, _parent = nil) dispatch end - # Test if generated object is not guarded from emitting - # - # @param [Object] object - # - # @return [Boolean] def new?(object) !object.eql?(input) end - # Dispatch node generations - # - # @return [undefined] abstract_method :dispatch + private :dispatch - # Emit generated mutation if object is not equivalent to input - # - # @param [Object] object - # - # @return [undefined] def emit(object) return unless new?(object) output << object end - # Run input with mutator - # - # @return [undefined] def run(mutator) mutator.call(input).each(&method(:emit)) end - # Shortcut to create a new unfrozen duplicate of input - # - # @return [Object] def dup_input input.dup end diff --git a/lib/mutant/mutator/node.rb b/lib/mutant/mutator/node.rb index d20784658..57131f7f2 100644 --- a/lib/mutant/mutator/node.rb +++ b/lib/mutant/mutator/node.rb @@ -34,21 +34,9 @@ def self.define_named_child(name, index) private - # Node to mutate - # - # @return [Parser::AST::Node] - alias_method :node, :input - - # Duplicate of original - # - # @return [Parser::AST::Node] + alias_method :node, :input alias_method :dup_node, :dup_input - # Dispatch on child index - # - # @param [Integer] index - # - # @return [undefined] def mutate_child(index, &block) block ||= TAUTOLOGY Mutator.mutate(children.fetch(index), self).each do |mutation| @@ -57,108 +45,55 @@ def mutate_child(index, &block) end end - # Emit delete child mutation - # - # @param [Integer] index - # - # @return [undefined] def delete_child(index) dup_children = children.dup dup_children.delete_at(index) emit_type(*dup_children) end - # Emit updated child - # - # @param [Integer] index - # @param [Parser::AST::Node] node - # - # @return [undefined] def emit_child_update(index, node) new_children = children.dup new_children[index] = node emit_type(*new_children) end - # Emit a new AST node with same class as wrapped node - # - # @param [Array] children - # - # @return [undefined] def emit_type(*children) emit(::Parser::AST::Node.new(node.type, children)) end - # Emit propagation if node can stand alone - # - # @return [undefined] def emit_propagation(node) emit(node) unless AST::Types::NOT_STANDALONE.include?(node.type) end - # Emit singleton literals - # - # @return [undefined] def emit_singletons emit_nil emit_self end - # Emit a literal self - # - # @return [undefined] def emit_self emit(N_SELF) end - # Emit a literal nil - # - # @return [undefined] def emit_nil emit(N_NIL) unless left_assignment? end - # Parent node - # - # @return [Parser::AST::Node] node - # if parent with node is present - # - # @return [nil] - # otherwise def parent_node parent&.node end - # Parent type - # - # @return [Symbol] type - # if parent with type is present - # - # @return [nil] - # otherwise def parent_type parent_node&.type end - # Test if the node is the left of an or_asgn or op_asgn - # - # @return [Boolean] def left_assignment? AST::Types::OP_ASSIGN.include?(parent_type) && parent.node.children.first.equal?(node) end - # Children indices - # - # @param [Range] range - # - # @return [Enumerable] def children_indices(range) range.begin.upto(children.length + range.end) end - # Emit single child mutation - # - # @return [undefined] def mutate_single_child children.each_with_index do |child, index| mutate_child(index) diff --git a/lib/mutant/mutator/node/and_asgn.rb b/lib/mutant/mutator/node/and_asgn.rb index dffd247e7..08d149d99 100644 --- a/lib/mutant/mutator/node/and_asgn.rb +++ b/lib/mutant/mutator/node/and_asgn.rb @@ -13,9 +13,6 @@ class AndAsgn < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_left_mutations do |node| diff --git a/lib/mutant/mutator/node/argument.rb b/lib/mutant/mutator/node/argument.rb index 52f0db757..cb10f35c7 100644 --- a/lib/mutant/mutator/node/argument.rb +++ b/lib/mutant/mutator/node/argument.rb @@ -14,24 +14,15 @@ class Argument < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_name_mutation end - # Emit name mutations - # - # @return [undefined] def emit_name_mutation return if skip? emit_name(:"#{UNDERSCORE}#{name}") end - # Test if argument mutation is skipped - # - # @return [Boolean] def skip? name.to_s.start_with?(UNDERSCORE) end @@ -50,18 +41,12 @@ class Optional < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_name_mutation emit_required_mutation emit_default_mutations end - # Emit required mutation - # - # @return [undefined] def emit_required_mutation emit(s(TYPE_MAP.fetch(node.type), name)) end diff --git a/lib/mutant/mutator/node/arguments.rb b/lib/mutant/mutator/node/arguments.rb index 8830e5c53..6f6505619 100644 --- a/lib/mutant/mutator/node/arguments.rb +++ b/lib/mutant/mutator/node/arguments.rb @@ -12,18 +12,12 @@ class Arguments < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_argument_presence emit_argument_mutations emit_mlhs_expansion end - # Emit argument presence mutation - # - # @return [undefined] def emit_argument_presence emit_type @@ -34,9 +28,6 @@ def emit_argument_presence end end - # Emit argument mutations - # - # @return [undefined] def emit_argument_mutations children.each_with_index do |child, index| Mutator.mutate(child).each do |mutant| @@ -46,18 +37,10 @@ def emit_argument_mutations end end - # Test if child mutation is allowed - # - # @param [Parser::AST::Node] - # - # @return [Boolean] def invalid_argument_replacement?(mutant, index) n_arg?(mutant) && children[0...index].any?(&method(:n_optarg?)) end - # Emit mlhs expansions - # - # @return [undefined] def emit_mlhs_expansion mlhs_childs_with_index.each do |child, index| dup_children = children.dup @@ -67,9 +50,6 @@ def emit_mlhs_expansion end end - # Multiple left hand side childs - # - # @return [Enumerable] def mlhs_childs_with_index children.each_with_index.select do |child,| n_mlhs?(child) diff --git a/lib/mutant/mutator/node/begin.rb b/lib/mutant/mutator/node/begin.rb index 666465e48..70c447c60 100644 --- a/lib/mutant/mutator/node/begin.rb +++ b/lib/mutant/mutator/node/begin.rb @@ -11,9 +11,6 @@ class Begin < self private - # Emit mutations - # - # @return [undefined] def dispatch mutate_single_child do |child| emit(child) diff --git a/lib/mutant/mutator/node/binary.rb b/lib/mutant/mutator/node/binary.rb index ea7c57ce1..3e2492bbf 100644 --- a/lib/mutant/mutator/node/binary.rb +++ b/lib/mutant/mutator/node/binary.rb @@ -17,9 +17,6 @@ class Binary < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_promotions @@ -29,35 +26,15 @@ def dispatch emit_right_mutations end - # Emit operator mutations - # - # @return [undefined] def emit_operator_mutations emit(s(INVERSE.fetch(node.type), left, right)) end - # Emit promotions - # - # @return [undefined] def emit_promotions emit(left) emit(right) end - # Emit left negation - # - # We do not emit right negation as the `and` and `or` nodes - # in ruby are also used for control flow. - # - # Irrespective of their syntax, aka `||` parses internally to `or`. - # - # `do_a or do_b`. Negating left makes sense, negating right - # only when the result is actually used. - # - # It *would* be possible to emit the right negation in case the use of the result is proved. - # Like parent is an assignment to an {l,i}var. Dunno if we ever get the time to do that. - # - # @return [undefined] def emit_left_negation emit(s(node.type, n_not(left), right)) end diff --git a/lib/mutant/mutator/node/block.rb b/lib/mutant/mutator/node/block.rb index b9cb3bc93..745f7b42c 100644 --- a/lib/mutant/mutator/node/block.rb +++ b/lib/mutant/mutator/node/block.rb @@ -11,9 +11,6 @@ class Block < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit(send) unless n_lambda?(send) @@ -23,9 +20,6 @@ def dispatch mutate_body end - # Emit body mutations - # - # @return [undefined] def mutate_body emit_body(nil) emit_body(N_RAISE) @@ -37,18 +31,12 @@ def mutate_body mutate_body_receiver end - # Test if body has control structures - # - # @return [Boolean] def body_has_control? AST.find_last_path(body) do |node| n_break?(node) || n_next?(node) end.any? end - # Mutate method send in body scope of `send` - # - # @return [undefined] def mutate_body_receiver return if n_lambda?(send) || !n_send?(body) @@ -57,9 +45,6 @@ def mutate_body_receiver emit(s(:send, send, body_meta.selector, *body_meta.arguments)) end - # Test for valid send mutations - # - # @return [true, false, nil] def valid_send_mutation?(node) return unless n_send?(node) diff --git a/lib/mutant/mutator/node/break.rb b/lib/mutant/mutator/node/break.rb index f942f76af..8e5c38e32 100644 --- a/lib/mutant/mutator/node/break.rb +++ b/lib/mutant/mutator/node/break.rb @@ -11,9 +11,6 @@ class Break < Generic private - # Emit mutations - # - # @return [undefined] def dispatch super() emit_singletons diff --git a/lib/mutant/mutator/node/case.rb b/lib/mutant/mutator/node/case.rb index 131bcff95..f181c6b33 100644 --- a/lib/mutant/mutator/node/case.rb +++ b/lib/mutant/mutator/node/case.rb @@ -13,9 +13,6 @@ class Case < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_condition_mutations if condition @@ -23,9 +20,6 @@ def dispatch emit_else_mutations end - # Emit when mutations - # - # @return [undefined] def emit_when_mutations indices = children.each_index.drop(1).take(children.length - 2) one = indices.one? @@ -35,9 +29,6 @@ def emit_when_mutations end end - # Emit else mutations - # - # @return [undefined] def emit_else_mutations else_branch = children.last else_index = children.length - 1 diff --git a/lib/mutant/mutator/node/class.rb b/lib/mutant/mutator/node/class.rb index 60a55f93f..11fcf0300 100644 --- a/lib/mutant/mutator/node/class.rb +++ b/lib/mutant/mutator/node/class.rb @@ -11,9 +11,6 @@ class Class < self private - # Emit mutations only for class body - # - # @return [undefined] def dispatch emit_body_mutations if body end diff --git a/lib/mutant/mutator/node/conditional_loop.rb b/lib/mutant/mutator/node/conditional_loop.rb index 68503ea12..23ecd74fd 100644 --- a/lib/mutant/mutator/node/conditional_loop.rb +++ b/lib/mutant/mutator/node/conditional_loop.rb @@ -13,9 +13,6 @@ class ConditionalLoop < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_condition_mutations diff --git a/lib/mutant/mutator/node/const.rb b/lib/mutant/mutator/node/const.rb index 598f494a0..79ed266ca 100644 --- a/lib/mutant/mutator/node/const.rb +++ b/lib/mutant/mutator/node/const.rb @@ -11,9 +11,6 @@ class Const < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons unless parent_node && n_const?(parent_node) emit_type(nil, *children.drop(1)) diff --git a/lib/mutant/mutator/node/define.rb b/lib/mutant/mutator/node/define.rb index 214a85575..cd09db1ec 100644 --- a/lib/mutant/mutator/node/define.rb +++ b/lib/mutant/mutator/node/define.rb @@ -8,9 +8,6 @@ class Define < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_arguments_mutations emit_optarg_body_assignments @@ -20,9 +17,6 @@ def dispatch emit_body_mutations if body end - # Emit mutations with optional arguments as assignments in method - # - # @return [undefined] def emit_optarg_body_assignments arguments.children.each do |argument| next unless n_optarg?(argument) && AST::Meta::Optarg.new(argument).used? @@ -31,11 +25,6 @@ def emit_optarg_body_assignments end end - # Emit valid body ASTs depending on instance body - # - # @param node [Parser::AST::Node] - # - # @return [undefined] def emit_body_prepend(node) if body emit_body(s(:begin, node, body)) diff --git a/lib/mutant/mutator/node/defined.rb b/lib/mutant/mutator/node/defined.rb index bd8c162f8..96898852c 100644 --- a/lib/mutant/mutator/node/defined.rb +++ b/lib/mutant/mutator/node/defined.rb @@ -12,9 +12,6 @@ class Defined < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit(N_TRUE) diff --git a/lib/mutant/mutator/node/dstr.rb b/lib/mutant/mutator/node/dstr.rb index 0bf262e50..48e2a39f9 100644 --- a/lib/mutant/mutator/node/dstr.rb +++ b/lib/mutant/mutator/node/dstr.rb @@ -11,9 +11,6 @@ class Dstr < Generic private - # Emit mutations - # - # @return [undefined] def dispatch super() emit_singletons diff --git a/lib/mutant/mutator/node/dsym.rb b/lib/mutant/mutator/node/dsym.rb index 15d3f7b63..015a572af 100644 --- a/lib/mutant/mutator/node/dsym.rb +++ b/lib/mutant/mutator/node/dsym.rb @@ -11,9 +11,6 @@ class Dsym < Generic private - # Emit mutations - # - # @return [undefined] def dispatch super() emit_singletons diff --git a/lib/mutant/mutator/node/generic.rb b/lib/mutant/mutator/node/generic.rb index ac13ae246..2d215ce30 100644 --- a/lib/mutant/mutator/node/generic.rb +++ b/lib/mutant/mutator/node/generic.rb @@ -8,9 +8,6 @@ class Generic < self private - # Emit mutations - # - # @return [undefined] def dispatch children.each_with_index do |child, index| mutate_child(index) if child.instance_of?(::Parser::AST::Node) diff --git a/lib/mutant/mutator/node/if.rb b/lib/mutant/mutator/node/if.rb index 845b81484..bc17454d4 100644 --- a/lib/mutant/mutator/node/if.rb +++ b/lib/mutant/mutator/node/if.rb @@ -12,9 +12,6 @@ class If < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons mutate_condition @@ -22,9 +19,6 @@ def dispatch mutate_else_branch end - # Emit condition mutations - # - # @return [undefined] def mutate_condition emit_condition_mutations do |node| !n_self?(node) @@ -34,9 +28,6 @@ def mutate_condition emit_type(N_FALSE, if_branch, else_branch) end - # Emit if branch mutations - # - # @return [undefined] def mutate_if_branch emit_type(condition, else_branch, nil) if else_branch return unless if_branch @@ -45,9 +36,6 @@ def mutate_if_branch emit_type(condition, if_branch, nil) end - # Emit else branch mutations - # - # @return [undefined] def mutate_else_branch return unless else_branch emit(else_branch) diff --git a/lib/mutant/mutator/node/index.rb b/lib/mutant/mutator/node/index.rb index dbd1fbefb..2063fb242 100644 --- a/lib/mutant/mutator/node/index.rb +++ b/lib/mutant/mutator/node/index.rb @@ -14,9 +14,6 @@ class Index < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_receiver_mutations { |node| !n_nil?(node) } @@ -26,9 +23,6 @@ def dispatch mutate_indices end - # Emit send forms - # - # @return [undefined] def emit_send_forms return if left_assignment? @@ -37,9 +31,6 @@ def emit_send_forms end end - # Emit mutation `foo[n..-1]` -> `foo.drop(n)` - # - # @return [undefined] def emit_drop_mutation return unless indices.one? && n_irange?(Mutant::Util.one(indices)) @@ -50,9 +41,6 @@ def emit_drop_mutation emit(s(:send, receiver, :drop, start)) end - # Mutate indices - # - # @return [undefined] def mutate_indices children_indices(index_range).each do |index| emit_propagation(children.fetch(index)) unless left_assignment? @@ -61,9 +49,6 @@ def mutate_indices end end - # The index nodes - # - # @return [Enumerable] def indices children[index_range] end @@ -74,9 +59,6 @@ class Read < self private - # The range index children can be found - # - # @return [Range] def index_range NO_VALUE_RANGE end @@ -92,9 +74,6 @@ class Assign < self private - # Emit mutations - # - # @return [undefined] def dispatch super() @@ -105,16 +84,10 @@ def dispatch mutate_child(children.length.pred) end - # Emit index read - # - # @return [undefined] def emit_index_read emit(s(:index, receiver, *children[index_range])) end - # Index indices - # - # @return [Range] def index_range if left_assignment? NO_VALUE_RANGE diff --git a/lib/mutant/mutator/node/kwbegin.rb b/lib/mutant/mutator/node/kwbegin.rb index 1576b837c..2b83f0dd5 100644 --- a/lib/mutant/mutator/node/kwbegin.rb +++ b/lib/mutant/mutator/node/kwbegin.rb @@ -11,9 +11,6 @@ class Kwbegin < Generic private - # Emit mutations - # - # @return [undefined] def dispatch super() emit_singletons diff --git a/lib/mutant/mutator/node/literal.rb b/lib/mutant/mutator/node/literal.rb index 63eb0aa52..2ae68498a 100644 --- a/lib/mutant/mutator/node/literal.rb +++ b/lib/mutant/mutator/node/literal.rb @@ -9,9 +9,6 @@ class Literal < self private - # Emit values - # - # @return [undefined] def emit_values values.each(&method(:emit_type)) end diff --git a/lib/mutant/mutator/node/literal/array.rb b/lib/mutant/mutator/node/literal/array.rb index 18dcb391b..34797db2b 100644 --- a/lib/mutant/mutator/node/literal/array.rb +++ b/lib/mutant/mutator/node/literal/array.rb @@ -13,9 +13,6 @@ class Array < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_type @@ -24,9 +21,6 @@ def dispatch emit(first) unless n_splat?(first) end - # Mutate body - # - # @return [undefined] def mutate_body children.each_index do |index| dup_children = children.dup diff --git a/lib/mutant/mutator/node/literal/boolean.rb b/lib/mutant/mutator/node/literal/boolean.rb index ab40fa820..8867862d2 100644 --- a/lib/mutant/mutator/node/literal/boolean.rb +++ b/lib/mutant/mutator/node/literal/boolean.rb @@ -16,9 +16,6 @@ class Boolean < self handle(*MAP.keys) - # Emit mutations - # - # @return [undefined] def dispatch emit(s(MAP.fetch(node.type))) end diff --git a/lib/mutant/mutator/node/literal/float.rb b/lib/mutant/mutator/node/literal/float.rb index 7786a4d46..7332200b1 100644 --- a/lib/mutant/mutator/node/literal/float.rb +++ b/lib/mutant/mutator/node/literal/float.rb @@ -11,9 +11,6 @@ class Float < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_values @@ -26,16 +23,10 @@ def dispatch N_INFINITY ].freeze - # Emit special cases - # - # @return [undefined] def emit_special_cases SPECIAL.each(&method(:emit)) end - # Values to mutate to - # - # @return [Array] def values original = children.first diff --git a/lib/mutant/mutator/node/literal/hash.rb b/lib/mutant/mutator/node/literal/hash.rb index 95576adbc..5bdefc219 100644 --- a/lib/mutant/mutator/node/literal/hash.rb +++ b/lib/mutant/mutator/node/literal/hash.rb @@ -11,18 +11,12 @@ class Hash < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_type mutate_body end - # Mutate body - # - # @return [undefined] def mutate_body children.each_index do |index| mutate_child(index) @@ -41,9 +35,6 @@ class Pair < Node private - # Emit mutations - # - # @return [undefined] def dispatch emit_key_mutations emit_value_mutations diff --git a/lib/mutant/mutator/node/literal/integer.rb b/lib/mutant/mutator/node/literal/integer.rb index 5a4ffbf99..b3e4f25ab 100644 --- a/lib/mutant/mutator/node/literal/integer.rb +++ b/lib/mutant/mutator/node/literal/integer.rb @@ -11,24 +11,15 @@ class Integer < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_values end - # Values to mutate to - # - # @return [Array] def values [0, 1, -value, value + 1, value - 1] end - # Literal original value - # - # @return [Object] def value value, = children value diff --git a/lib/mutant/mutator/node/literal/nil.rb b/lib/mutant/mutator/node/literal/nil.rb index d238573b4..88f3153be 100644 --- a/lib/mutant/mutator/node/literal/nil.rb +++ b/lib/mutant/mutator/node/literal/nil.rb @@ -11,9 +11,6 @@ class Nil < self private - # Emit mutations - # - # @return [undefined] def dispatch; end end # Nil diff --git a/lib/mutant/mutator/node/literal/range.rb b/lib/mutant/mutator/node/literal/range.rb index 8665b50b3..2346610ca 100644 --- a/lib/mutant/mutator/node/literal/range.rb +++ b/lib/mutant/mutator/node/literal/range.rb @@ -19,9 +19,6 @@ class Range < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_inverse @@ -29,9 +26,6 @@ def dispatch emit_upper_bound_mutations end - # Inverse node - # - # @return [Parser::AST::Node] def emit_inverse emit(s(MAP.fetch(node.type), *children)) end diff --git a/lib/mutant/mutator/node/literal/regex.rb b/lib/mutant/mutator/node/literal/regex.rb index 47ae6805b..b208b0253 100644 --- a/lib/mutant/mutator/node/literal/regex.rb +++ b/lib/mutant/mutator/node/literal/regex.rb @@ -14,16 +14,10 @@ class Regex < self private - # Original regexp options - # - # @return [Parser::AST::Node] def options children.last end - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons unless parent_node children.each_with_index do |child, index| diff --git a/lib/mutant/mutator/node/literal/string.rb b/lib/mutant/mutator/node/literal/string.rb index 473f20e38..7d7755fda 100644 --- a/lib/mutant/mutator/node/literal/string.rb +++ b/lib/mutant/mutator/node/literal/string.rb @@ -11,9 +11,6 @@ class String < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons end diff --git a/lib/mutant/mutator/node/literal/symbol.rb b/lib/mutant/mutator/node/literal/symbol.rb index c0881566e..7dae92871 100644 --- a/lib/mutant/mutator/node/literal/symbol.rb +++ b/lib/mutant/mutator/node/literal/symbol.rb @@ -15,9 +15,6 @@ class Symbol < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons Util::Symbol.call(value).each(&method(:emit_type)) diff --git a/lib/mutant/mutator/node/masgn.rb b/lib/mutant/mutator/node/masgn.rb index 8ac5c3d13..28156cf7f 100644 --- a/lib/mutant/mutator/node/masgn.rb +++ b/lib/mutant/mutator/node/masgn.rb @@ -13,9 +13,6 @@ class MultipleAssignment < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons end diff --git a/lib/mutant/mutator/node/match_current_line.rb b/lib/mutant/mutator/node/match_current_line.rb index 759b38045..3a7001719 100644 --- a/lib/mutant/mutator/node/match_current_line.rb +++ b/lib/mutant/mutator/node/match_current_line.rb @@ -12,9 +12,6 @@ class MatchCurrentLine < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_regexp_mutations diff --git a/lib/mutant/mutator/node/mlhs.rb b/lib/mutant/mutator/node/mlhs.rb index 02632ec18..e7de36270 100644 --- a/lib/mutant/mutator/node/mlhs.rb +++ b/lib/mutant/mutator/node/mlhs.rb @@ -10,9 +10,6 @@ class MLHS < self private - # Emit mutations - # - # @return [undefined] def dispatch mutate_single_child do |_child, index| delete_child(index) diff --git a/lib/mutant/mutator/node/named_value/access.rb b/lib/mutant/mutator/node/named_value/access.rb index 67ef182e6..a6d07cbeb 100644 --- a/lib/mutant/mutator/node/named_value/access.rb +++ b/lib/mutant/mutator/node/named_value/access.rb @@ -12,9 +12,6 @@ class Access < Node private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons end @@ -27,26 +24,17 @@ class Ivar < Access children :name - # Emit mutations - # - # @return [undefined] + private + def dispatch emit_attribute_read super() end - private - - # Emit instance variable as attribute send - # - # @return [undefined] def emit_attribute_read emit(s(:send, nil, attribute_name)) end - # Variable name without leading '@' - # - # @return [Symbol] def attribute_name name.slice(NAME_RANGE).to_sym end diff --git a/lib/mutant/mutator/node/named_value/constant_assignment.rb b/lib/mutant/mutator/node/named_value/constant_assignment.rb index 35745e743..a31a832a3 100644 --- a/lib/mutant/mutator/node/named_value/constant_assignment.rb +++ b/lib/mutant/mutator/node/named_value/constant_assignment.rb @@ -14,9 +14,6 @@ class ConstantAssignment < Node private - # Emit mutations - # - # @return [undefined] def dispatch mutate_name return unless value # op asgn @@ -24,16 +21,10 @@ def dispatch emit_remove_const end - # Emit remove_const - # - # @return [undefined] def emit_remove_const emit(s(:send, cbase, :remove_const, s(:sym, name))) end - # Emit name mutations - # - # @return [undefined] def mutate_name Util::Symbol.call(name).each do |name| emit_name(name.upcase) diff --git a/lib/mutant/mutator/node/named_value/variable_assignment.rb b/lib/mutant/mutator/node/named_value/variable_assignment.rb index 3d10bf6c0..9d3735523 100644 --- a/lib/mutant/mutator/node/named_value/variable_assignment.rb +++ b/lib/mutant/mutator/node/named_value/variable_assignment.rb @@ -25,18 +25,12 @@ class VariableAssignment < Node private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons mutate_name emit_value_mutations if value # op asgn! end - # Emit name mutations - # - # @return [undefined] def mutate_name prefix, regexp = MAP.fetch(node.type) stripped = name.to_s.sub(regexp, EMPTY_STRING) diff --git a/lib/mutant/mutator/node/next.rb b/lib/mutant/mutator/node/next.rb index a58c917c1..9397b2543 100644 --- a/lib/mutant/mutator/node/next.rb +++ b/lib/mutant/mutator/node/next.rb @@ -11,9 +11,6 @@ class Next < Generic private - # Emit mutations - # - # @return [undefined] def dispatch super() emit_singletons diff --git a/lib/mutant/mutator/node/noop.rb b/lib/mutant/mutator/node/noop.rb index 078d85bd6..a56b8a0ce 100644 --- a/lib/mutant/mutator/node/noop.rb +++ b/lib/mutant/mutator/node/noop.rb @@ -11,9 +11,6 @@ class Noop < self private - # Emit mutations - # - # @return [undefined] def dispatch # noop end diff --git a/lib/mutant/mutator/node/nthref.rb b/lib/mutant/mutator/node/nthref.rb index e1aa3c300..ff4e32f45 100644 --- a/lib/mutant/mutator/node/nthref.rb +++ b/lib/mutant/mutator/node/nthref.rb @@ -12,9 +12,6 @@ class NthRef < self private - # Emit mutations - # - # @return [undefined] def dispatch unless number.equal?(1) emit_number(number - 1) diff --git a/lib/mutant/mutator/node/op_asgn.rb b/lib/mutant/mutator/node/op_asgn.rb index b41056939..d6affbdd9 100644 --- a/lib/mutant/mutator/node/op_asgn.rb +++ b/lib/mutant/mutator/node/op_asgn.rb @@ -13,9 +13,6 @@ class OpAsgn < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_left_mutations do |node| diff --git a/lib/mutant/mutator/node/or_asgn.rb b/lib/mutant/mutator/node/or_asgn.rb index 1d0aae7d4..d8a4a7d90 100644 --- a/lib/mutant/mutator/node/or_asgn.rb +++ b/lib/mutant/mutator/node/or_asgn.rb @@ -13,9 +13,6 @@ class OrAsgn < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_right_mutations diff --git a/lib/mutant/mutator/node/procarg_zero.rb b/lib/mutant/mutator/node/procarg_zero.rb index 30c9af4a1..a634bc853 100644 --- a/lib/mutant/mutator/node/procarg_zero.rb +++ b/lib/mutant/mutator/node/procarg_zero.rb @@ -17,9 +17,6 @@ class ProcargZero < self private - # Emit mutations - # - # @return [undefined] def dispatch name = Mutant::Util.one(argument.children) diff --git a/lib/mutant/mutator/node/regopt.rb b/lib/mutant/mutator/node/regopt.rb index f43e3a23d..c95c133d7 100644 --- a/lib/mutant/mutator/node/regopt.rb +++ b/lib/mutant/mutator/node/regopt.rb @@ -13,16 +13,10 @@ class Regopt < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_type(*mutated_flags) end - # Altered flags array excluding case insensitive flag - # - # @return [Array] def mutated_flags (children - MUTATED_FLAGS) end diff --git a/lib/mutant/mutator/node/resbody.rb b/lib/mutant/mutator/node/resbody.rb index b7b5d1481..ca8b6cb21 100644 --- a/lib/mutant/mutator/node/resbody.rb +++ b/lib/mutant/mutator/node/resbody.rb @@ -12,18 +12,12 @@ class Resbody < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_assignment(nil) emit_body_mutations if body mutate_captures end - # Mutate captures - # - # @return [undefined] def mutate_captures return unless captures Util::Array::Element.call(captures.children).each do |matchers| diff --git a/lib/mutant/mutator/node/rescue.rb b/lib/mutant/mutator/node/rescue.rb index 793906061..c9858ed18 100644 --- a/lib/mutant/mutator/node/rescue.rb +++ b/lib/mutant/mutator/node/rescue.rb @@ -14,20 +14,14 @@ class Rescue < self RESCUE_INDICES = (1..-2).freeze - # Emit mutations - # - # @return [undefined] + private + def dispatch mutate_body mutate_rescue_bodies mutate_else_body end - private - - # Mutate child by name - # - # @return [undefined] def mutate_rescue_bodies children_indices(RESCUE_INDICES).each do |index| mutate_child(index) @@ -36,11 +30,6 @@ def mutate_rescue_bodies end end - # Emit concatenation with body - # - # @param [Parser::AST::Node] child - # - # @return [undefined] def emit_concat(child) if body emit(s(:begin, body, child)) @@ -49,18 +38,12 @@ def emit_concat(child) end end - # Emit body mutations - # - # @return [undefined] def mutate_body return unless body emit_body_mutations emit(body) end - # Emit else body mutations - # - # @return [undefined] def mutate_else_body return unless else_body emit_else_body_mutations diff --git a/lib/mutant/mutator/node/return.rb b/lib/mutant/mutator/node/return.rb index d42dc8b27..289f2c630 100644 --- a/lib/mutant/mutator/node/return.rb +++ b/lib/mutant/mutator/node/return.rb @@ -12,9 +12,6 @@ class Return < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons return unless value diff --git a/lib/mutant/mutator/node/send.rb b/lib/mutant/mutator/node/send.rb index 75c0690c1..4fe45c44a 100644 --- a/lib/mutant/mutator/node/send.rb +++ b/lib/mutant/mutator/node/send.rb @@ -48,9 +48,6 @@ class Send < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons @@ -63,23 +60,14 @@ def dispatch end end - # AST metadata for node - # - # @return [AST::Meta::Send] def meta AST::Meta::Send.new(node) end memoize :meta - # Arguments being send - # - # @return [Enumerable] alias_method :arguments, :remaining_children private :arguments - # Perform normal, non special case dispatch - # - # @return [undefined] def normal_dispatch emit_naked_receiver emit_selector_replacement @@ -90,9 +78,6 @@ def normal_dispatch mutate_arguments end - # Emit mutations which only correspond to one selector - # - # @return [undefined] def emit_selector_specific_mutations emit_const_get_mutation emit_integer_mutation @@ -101,9 +86,6 @@ def emit_selector_specific_mutations emit_lambda_mutation end - # Emit selector mutations specific to top level constants - # - # @return [undefined] def emit_receiver_selector_mutations return unless meta.receiver_possible_top_level_const? @@ -113,9 +95,6 @@ def emit_receiver_selector_mutations .each(&method(:emit_selector)) end - # Emit mutation from `!!foo` to `foo` - # - # @return [undefined] def emit_double_negation_mutation return unless selector.equal?(:!) && n_send?(receiver) @@ -123,19 +102,10 @@ def emit_double_negation_mutation emit(negated.receiver) if negated.selector.equal?(:!) end - # Emit mutation from proc definition to lambda - # - # @return [undefined] def emit_lambda_mutation emit(s(:send, nil, :lambda)) if meta.proc? end - # Emit mutation for `#dig` - # - # - Mutates `foo.dig(a, b)` to `foo.fetch(a).dig(b)` - # - Mutates `foo.dig(a)` to `foo.fetch(a)` - # - # @return [undefined] def emit_dig_mutation return if !selector.equal?(:dig) || arguments.none? @@ -148,41 +118,26 @@ def emit_dig_mutation emit(s(:send, fetch_mutation, :dig, *tail)) end - # Emit mutation from `to_i` to `Integer(...)` - # - # @return [undefined] def emit_integer_mutation return unless selector.equal?(:to_i) emit(s(:send, nil, :Integer, receiver)) end - # Emit mutation from `const_get` to const literal - # - # @return [undefined] def emit_const_get_mutation return unless selector.equal?(:const_get) && n_sym?(arguments.first) emit(s(:const, receiver, AST::Meta::Symbol.new(arguments.first).name)) end - # Emit selector replacement - # - # @return [undefined] def emit_selector_replacement SELECTOR_REPLACEMENTS.fetch(selector, EMPTY_ARRAY).each(&method(:emit_selector)) end - # Emit naked receiver mutation - # - # @return [undefined] def emit_naked_receiver emit(receiver) if receiver end - # Mutate arguments - # - # @return [undefined] def mutate_arguments emit_type(receiver, selector) remaining_children_with_index.each do |_node, index| @@ -191,25 +146,14 @@ def mutate_arguments end end - # Mutate argument - # - # @param [Integer] index - # - # @return [undefined] def mutate_argument_index(index) mutate_child(index) { |node| !n_begin?(node) } end - # Emit argument propagation - # - # @return [undefined] def emit_argument_propagation emit_propagation(Mutant::Util.one(arguments)) if arguments.one? end - # Emit receiver mutations - # - # @return [undefined] def mutate_receiver return unless receiver emit_implicit_self @@ -218,9 +162,6 @@ def mutate_receiver end end - # Emit implicit self mutation - # - # @return [undefined] def emit_implicit_self emit_receiver(nil) if n_self?(receiver) && !( KEYWORDS.include?(selector) || diff --git a/lib/mutant/mutator/node/send/attribute_assignment.rb b/lib/mutant/mutator/node/send/attribute_assignment.rb index 124915d21..b60143846 100644 --- a/lib/mutant/mutator/node/send/attribute_assignment.rb +++ b/lib/mutant/mutator/node/send/attribute_assignment.rb @@ -12,26 +12,17 @@ class AttributeAssignment < self private - # Emit mutations - # - # @return [undefined] def dispatch normal_dispatch emit_attribute_read end - # Mutate arguments - # - # @return [undefined] def mutate_arguments remaining_children_indices.each do |index| mutate_child(index) end end - # Emit attribute read - # - # @return [undefined] def emit_attribute_read emit_type(receiver, selector[ATTRIBUTE_RANGE].to_sym) end diff --git a/lib/mutant/mutator/node/send/binary.rb b/lib/mutant/mutator/node/send/binary.rb index 5fefc7925..687168bc6 100644 --- a/lib/mutant/mutator/node/send/binary.rb +++ b/lib/mutant/mutator/node/send/binary.rb @@ -12,9 +12,6 @@ class Binary < self private - # Emit mutations - # - # @return [undefined] def dispatch emit(left) emit_left_mutations @@ -24,9 +21,6 @@ def dispatch emit_not_equality_mutations end - # Emit mutations for `!=` - # - # @return [undefined] def emit_not_equality_mutations return unless operator.equal?(:'!=') @@ -34,11 +28,6 @@ def emit_not_equality_mutations emit_not_equality_mutation(:equal?) end - # Emit negated method sends with specified operator - # - # @param new_operator [Symbol] selector to be negated - # - # @return [undefined] def emit_not_equality_mutation(new_operator) emit(n_not(s(:send, left, new_operator, right))) end diff --git a/lib/mutant/mutator/node/send/conditional.rb b/lib/mutant/mutator/node/send/conditional.rb index 3631411e7..084d4c436 100644 --- a/lib/mutant/mutator/node/send/conditional.rb +++ b/lib/mutant/mutator/node/send/conditional.rb @@ -10,9 +10,6 @@ class Conditional < self private - # Emit mutations - # - # @return [undefined] def dispatch super() emit(s(:send, *children)) diff --git a/lib/mutant/mutator/node/splat.rb b/lib/mutant/mutator/node/splat.rb index a67bcda4e..1b79dc9a0 100644 --- a/lib/mutant/mutator/node/splat.rb +++ b/lib/mutant/mutator/node/splat.rb @@ -12,9 +12,6 @@ class Splat < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit_expression_mutations diff --git a/lib/mutant/mutator/node/super.rb b/lib/mutant/mutator/node/super.rb index 89d7fe8c2..e9db4ecd7 100644 --- a/lib/mutant/mutator/node/super.rb +++ b/lib/mutant/mutator/node/super.rb @@ -11,9 +11,6 @@ class Super < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit(N_EMPTY_SUPER) diff --git a/lib/mutant/mutator/node/when.rb b/lib/mutant/mutator/node/when.rb index d2571184a..bb3ebf625 100644 --- a/lib/mutant/mutator/node/when.rb +++ b/lib/mutant/mutator/node/when.rb @@ -11,9 +11,6 @@ class When < self private - # Emit mutations - # - # @return [undefined] def dispatch if body mutate_body @@ -23,9 +20,6 @@ def dispatch mutate_conditions end - # Emit condition mutations - # - # @return [undefined] def mutate_conditions conditions = children.length - 1 children[0..-2].each_index do |index| @@ -34,27 +28,14 @@ def mutate_conditions end end - # Emit body mutations - # - # @return [undefined] def mutate_body mutate_child(body_index) end - # Body node - # - # @return [Parser::AST::Node] - # if body is present - # - # @return [nil] - # otherwise def body children.fetch(body_index) end - # Index of body node - # - # @return [Integer] def body_index children.length - 1 end diff --git a/lib/mutant/mutator/node/yield.rb b/lib/mutant/mutator/node/yield.rb index cbe3f6e7e..be84829d5 100644 --- a/lib/mutant/mutator/node/yield.rb +++ b/lib/mutant/mutator/node/yield.rb @@ -11,9 +11,6 @@ class Yield < Generic private - # Emit mutations - # - # @return [undefined] def dispatch super() emit_singletons diff --git a/lib/mutant/mutator/node/zsuper.rb b/lib/mutant/mutator/node/zsuper.rb index c0ab43c03..e1918af27 100644 --- a/lib/mutant/mutator/node/zsuper.rb +++ b/lib/mutant/mutator/node/zsuper.rb @@ -11,9 +11,6 @@ class ZSuper < self private - # Emit mutations - # - # @return [undefined] def dispatch emit_singletons emit(N_EMPTY_SUPER) diff --git a/lib/mutant/mutator/util/array.rb b/lib/mutant/mutator/util/array.rb index c5710b825..f58468aa1 100644 --- a/lib/mutant/mutator/util/array.rb +++ b/lib/mutant/mutator/util/array.rb @@ -12,9 +12,6 @@ class Presence < Util private - # Emit element presence mutations - # - # @return [undefined] def dispatch input.each_index do |index| dup = dup_input @@ -30,9 +27,6 @@ class Element < Util private - # Emit mutations - # - # @return [undefined] def dispatch input.each_with_index do |element, index| Mutator.mutate(element).each do |mutation| diff --git a/lib/mutant/mutator/util/symbol.rb b/lib/mutant/mutator/util/symbol.rb index 6b81106e8..dfaccef45 100644 --- a/lib/mutant/mutator/util/symbol.rb +++ b/lib/mutant/mutator/util/symbol.rb @@ -11,9 +11,6 @@ class Symbol < self private - # Emit mutations - # - # @return [undefined] def dispatch emit((input.to_s + POSTFIX).to_sym) end diff --git a/lib/mutant/parallel.rb b/lib/mutant/parallel.rb index 9e9f7f66a..5fe3d7992 100644 --- a/lib/mutant/parallel.rb +++ b/lib/mutant/parallel.rb @@ -36,24 +36,11 @@ def self.worker(config, **shared) ) end - # Start threads - # - # @param [Config] config - # @param [Worker] worker - # - # @return [Array] def self.threads(config, worker) Array.new(config.jobs) { config.thread.new(&worker.method(:call)) } end private_class_method :threads - # Create shared variable - # - # @param [Class] klass - # @param [Config] config - # - # @return [Variable] - # # ignore :reek:LongParameterList def self.shared(klass, config, **attributes) klass.new( diff --git a/lib/mutant/parallel/driver.rb b/lib/mutant/parallel/driver.rb index f651f2eed..0d540985d 100644 --- a/lib/mutant/parallel/driver.rb +++ b/lib/mutant/parallel/driver.rb @@ -27,22 +27,12 @@ def wait_timeout(timeout) private - # Possibly finalize the exeuction - # - # @param [Status] - # - # @return [Status] def finalize(status) status.tap do threads.each(&:join) if status.done? end end - # Get status - # - # @return [Status] - # - # ignore :reek:NestedIterators def status var_active_jobs.with do |active_jobs| var_sink.with do |sink| diff --git a/lib/mutant/parallel/worker.rb b/lib/mutant/parallel/worker.rb index d23d9081e..b2b102d96 100644 --- a/lib/mutant/parallel/worker.rb +++ b/lib/mutant/parallel/worker.rb @@ -39,20 +39,12 @@ def call private - # Next job, if any - # - # @return [Job, nil] def next_job var_source.with do |source| source.next if source.next? end end - # Add result - # - # @param [Object] result - # - # @return [Boolean] def add_result(result) var_sink.with do |sink| sink.result(result) @@ -60,32 +52,18 @@ def add_result(result) end end - # Register job to be started - # - # @param [Job] job - # - # @return [undefined] def job_start(job) var_active_jobs.with do |active_jobs| active_jobs << job end end - # Register job to be done - # - # @param [Job] job - # @param [Object] result - # - # @return [undefined] def job_done(job) var_active_jobs.with do |active_jobs| active_jobs.delete(job) end end - # Finalize worker - # - # @return [undefined] def finalize var_final.put(nil) if var_running.modify(&:pred).zero? end diff --git a/lib/mutant/reporter/cli.rb b/lib/mutant/reporter/cli.rb index 0a1c2ab1a..a30bf52c4 100644 --- a/lib/mutant/reporter/cli.rb +++ b/lib/mutant/reporter/cli.rb @@ -69,11 +69,6 @@ def report(env) private - # Write output frame - # - # @param [String] frame - # - # @return [undefined] def write(frame) output.write(frame) end diff --git a/lib/mutant/reporter/cli/format.rb b/lib/mutant/reporter/cli/format.rb index 592eded25..f6b7daa8d 100644 --- a/lib/mutant/reporter/cli/format.rb +++ b/lib/mutant/reporter/cli/format.rb @@ -49,12 +49,6 @@ class Output private - # Format object with printer - # - # @param [Class:Printer] printer - # @param [Object] object - # - # @return [String] def format(printer, object) buffer = new_buffer printer.call(Output.new(tty, buffer), object) @@ -84,9 +78,6 @@ def progress(status) private - # New buffer - # - # @return [StringIO] def new_buffer StringIO.new end diff --git a/lib/mutant/reporter/cli/printer.rb b/lib/mutant/reporter/cli/printer.rb index 4eded657f..cc0039385 100644 --- a/lib/mutant/reporter/cli/printer.rb +++ b/lib/mutant/reporter/cli/printer.rb @@ -44,81 +44,41 @@ def self.define_delegator(name) private - # Status color - # - # @return [Color] def status_color success? ? Color::GREEN : Color::RED end - # Visit a collection of objects - # - # @return [Class::Printer] printer - # @return [Enumerable] collection - # - # @return [undefined] def visit_collection(printer, collection) collection.each do |object| visit(printer, object) end end - # Visit object - # - # @param [Class::Printer] printer - # @param [Object] object - # - # @return [undefined] def visit(printer, object) printer.call(output, object) end - # Print an info line to output - # - # @return [undefined] def info(string, *arguments) puts(string % arguments) end - # Print a status line to output - # - # @return [undefined] def status(string, *arguments) puts(colorize(status_color, string % arguments)) end - # Print a line to output - # - # @return [undefined] def puts(string) output.puts(string) end - # Colorize message - # - # @param [Color] color - # @param [String] message - # - # @return [String] - # if color is enabled - # unmodified message otherwise def colorize(color, message) color = Color::NONE unless tty? color.format(message) end - # Test if output is a tty - # - # @return [Boolean] def tty? output.tty? end - # Test if output can be colored - # - # @return [Boolean] - # - # @api private alias_method :color?, :tty? end # Printer end # CLI diff --git a/lib/mutant/reporter/cli/printer/env_progress.rb b/lib/mutant/reporter/cli/printer/env_progress.rb index 67cfd4481..2d32b9889 100644 --- a/lib/mutant/reporter/cli/printer/env_progress.rb +++ b/lib/mutant/reporter/cli/printer/env_progress.rb @@ -40,29 +40,14 @@ def run private - # Mutations processed per second - # - # @return [Float] - # - # @api private def mutations_per_second amount_mutation_results / runtime end - # Coverage in percent - # - # @return [Float] - # - # @api private def coverage_percent coverage * 100 end - # Overhead in percent - # - # @return [Float] - # - # @api private def overhead_percent (overhead / killtime) * 100 end diff --git a/lib/mutant/reporter/cli/printer/isolation_result.rb b/lib/mutant/reporter/cli/printer/isolation_result.rb index ce40de17c..39ba58161 100644 --- a/lib/mutant/reporter/cli/printer/isolation_result.rb +++ b/lib/mutant/reporter/cli/printer/isolation_result.rb @@ -66,39 +66,24 @@ def run private - # Visit successful isolation result - # - # @return [undefined] def visit_success visit(TestResult, object.value) end - # Print log messages - # - # @return [undefined] def print_log_messages log = object.log puts(LOG_MESSAGES % log) unless log.empty? end - # Visit child error isolation result - # - # @return [undefined] def visit_child_error puts(CHILD_ERROR_MESSAGE % object.value.inspect) end - # Visit fork error isolation result - # - # @return [undefined] def visit_fork_error puts(FORK_ERROR_MESSAGE) end - # Visit exception isolation result - # - # @return [undefined] def visit_exception exception = object.value @@ -110,9 +95,6 @@ def visit_exception ) end - # Visit chain - # - # @return [undefined] def visit_chain printer = self.class diff --git a/lib/mutant/reporter/cli/printer/mutation_progress_result.rb b/lib/mutant/reporter/cli/printer/mutation_progress_result.rb index 91c9f701e..41a4bef96 100644 --- a/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +++ b/lib/mutant/reporter/cli/printer/mutation_progress_result.rb @@ -18,11 +18,6 @@ def run private - # Write colorized char - # - # @param [String] char - # - # @return [undefined] def char(char) output.write(colorize(status_color, char)) end diff --git a/lib/mutant/reporter/cli/printer/mutation_result.rb b/lib/mutant/reporter/cli/printer/mutation_result.rb index a486a3456..b16118cf6 100644 --- a/lib/mutant/reporter/cli/printer/mutation_result.rb +++ b/lib/mutant/reporter/cli/printer/mutation_result.rb @@ -59,9 +59,6 @@ def run private - # Print mutation details - # - # @return [undefined] def print_details __send__(MAP.fetch(mutation.class)) @@ -69,9 +66,6 @@ def print_details visit_isolation_result end - # Evil mutation details - # - # @return [String] def evil_details diff = Diff.build(mutation.original_source, mutation.source) diff = color? ? diff.colorized_diff : diff.diff @@ -82,9 +76,6 @@ def evil_details end end - # Print no diff message - # - # @return [undefined] def print_no_diff_message info( NO_DIFF_MESSAGE, @@ -95,30 +86,18 @@ def print_no_diff_message ) end - # Noop details - # - # @return [String] def noop_details info(NOOP_MESSAGE) end - # Neutral details - # - # @return [String] def neutral_details info(NEUTRAL_MESSAGE, original_node.inspect, mutation.source) end - # Visit failed test results - # - # @return [undefined] def visit_isolation_result visit(IsolationResult, isolation_result) end - # Original node - # - # @return [Parser::AST::Node] def original_node mutation.subject.node end diff --git a/lib/mutant/reporter/cli/printer/status_progressive.rb b/lib/mutant/reporter/cli/printer/status_progressive.rb index 6dc0b1402..862d4a7e5 100644 --- a/lib/mutant/reporter/cli/printer/status_progressive.rb +++ b/lib/mutant/reporter/cli/printer/status_progressive.rb @@ -35,18 +35,10 @@ def run private - # Object being printed - # - # @return [Result::Env] def object super().payload end - # Mutations processed per second - # - # @return [Float] - # - # @api private def mutations_per_second amount_mutation_results / runtime end diff --git a/lib/mutant/reporter/cli/printer/subject_progress.rb b/lib/mutant/reporter/cli/printer/subject_progress.rb index 0a664434b..cd5071d2c 100644 --- a/lib/mutant/reporter/cli/printer/subject_progress.rb +++ b/lib/mutant/reporter/cli/printer/subject_progress.rb @@ -32,9 +32,6 @@ def run private - # Print stats - # - # @return [undefined] def print_stats status( FORMAT, @@ -47,16 +44,10 @@ def print_stats ) end - # Print progress bar finish - # - # @return [undefined] def print_progress_bar_finish puts(nil) unless amount_mutation_results.zero? end - # Print mutation results - # - # @return [undefined] def print_mutation_results visit_collection(MutationProgressResult, object.mutation_results) end diff --git a/lib/mutant/repository/diff.rb b/lib/mutant/repository/diff.rb index 22c4b5155..2587f8888 100644 --- a/lib/mutant/repository/diff.rb +++ b/lib/mutant/repository/diff.rb @@ -29,10 +29,6 @@ def touches?(path, line_range) private - # Touched paths - # - # @return [Hash{Pathname => Path}] - # # rubocop:disable Metrics/MethodLength def touched_paths pathname = world.pathname @@ -49,13 +45,8 @@ def touched_paths .to_h end memoize :touched_paths + # rubocop:enable Metrics/MethodLength - # Parse path - # - # @param [Pathname] work_dir - # @param [String] line - # - # @return [Path] def parse_line(work_dir, line) match = FORMAT.match(line) or fail Error, "Invalid git diff-index line: #{line}" @@ -88,9 +79,6 @@ def touches?(line_range) private - # Ranges of hunks in the diff - # - # @return [Array>] def diff_ranges world .capture_stdout(%W[git diff --unified=0 #{to} -- #{path}]) diff --git a/lib/mutant/repository/diff/ranges.rb b/lib/mutant/repository/diff/ranges.rb index ec1dc6d84..82f6fa2cf 100644 --- a/lib/mutant/repository/diff/ranges.rb +++ b/lib/mutant/repository/diff/ranges.rb @@ -18,11 +18,6 @@ def self.parse(diff) diff.lines.flat_map(&method(:parse_ranges)).to_set end - # Parse ranges from line - # - # @param [String] line - # - # @return [Array>] def self.parse_ranges(line) match = REGEXP.match(line) or return EMPTY_ARRAY @@ -34,12 +29,6 @@ def self.parse_ranges(line) end private_class_method :parse_ranges - # Construct a range from start point and offset - # - # @param [String] start - # @param [String, nil] offset - # - # @return [Range] def self.mk_range(start, offset) start = Integer(start) diff --git a/lib/mutant/result.rb b/lib/mutant/result.rb index 0f4706952..d08c54356 100644 --- a/lib/mutant/result.rb +++ b/lib/mutant/result.rb @@ -193,9 +193,6 @@ def amount_mutations_alive private - # Killed mutation results - # - # @return [Array] def killed_mutation_results mutation_results.select(&:success?) end diff --git a/lib/mutant/runner.rb b/lib/mutant/runner.rb index 3afc82294..0d4d9b667 100644 --- a/lib/mutant/runner.rb +++ b/lib/mutant/runner.rb @@ -12,9 +12,6 @@ def self.apply(env) Either::Right.new(run_mutation_analysis(env)) end - # Run mutation analysis - # - # @return [undefined] def self.run_mutation_analysis(env) reporter = reporter(env) @@ -27,13 +24,6 @@ def self.run_mutation_analysis(env) end private_class_method :run_mutation_analysis - # Run driver - # - # @param [Reporter] reporter - # @param [Driver] driver - # - # @return [Object] - # the last returned status payload def self.run_driver(reporter, driver) loop do status = driver.wait_timeout(reporter.delay) @@ -43,9 +33,6 @@ def self.run_driver(reporter, driver) end private_class_method :run_driver - # Configuration for parallel execution engine - # - # @return [Parallell::Config] def self.mutation_test_config(env) world = env.world @@ -61,11 +48,6 @@ def self.mutation_test_config(env) end private_class_method :mutation_test_config - # Reporter to use - # - # @param [Env] env - # - # @return [Reporter] def self.reporter(env) env.config.reporter end diff --git a/lib/mutant/runner/sink.rb b/lib/mutant/runner/sink.rb index 8771fd664..15f959356 100644 --- a/lib/mutant/runner/sink.rb +++ b/lib/mutant/runner/sink.rb @@ -51,11 +51,6 @@ def result(mutation_result) private - # Return previous results - # - # @param [Subject] - # - # @return [Array] def previous_mutation_results(subject) subject_result = @subject_results.fetch(subject) { return EMPTY_ARRAY } subject_result.mutation_results diff --git a/lib/mutant/subject.rb b/lib/mutant/subject.rb index 2a7ed097a..89160ad83 100644 --- a/lib/mutant/subject.rb +++ b/lib/mutant/subject.rb @@ -79,18 +79,10 @@ def source private - # Neutral mutation - # - # @return [Mutation::Neutral] def neutral_mutation Mutation::Neutral.new(self, wrap_node(node)) end - # Wrap node into subject specific container - # - # @param [Parser::AST::Node] node - # - # @return [Parser::AST::Node] def wrap_node(node) node end diff --git a/lib/mutant/subject/method.rb b/lib/mutant/subject/method.rb index 8ab3995e7..afffebb00 100644 --- a/lib/mutant/subject/method.rb +++ b/lib/mutant/subject/method.rb @@ -34,9 +34,6 @@ def match_expressions private - # The scope - # - # @return [Class, Module] def scope context.scope end diff --git a/lib/mutant/subject/method/instance.rb b/lib/mutant/subject/method/instance.rb index 662453f51..76b0612a5 100644 --- a/lib/mutant/subject/method/instance.rb +++ b/lib/mutant/subject/method/instance.rb @@ -33,11 +33,6 @@ def prepare private - # Memoizer node for mutant - # - # @param [Parser::AST::Node] mutant - # - # @return [Parser::AST::Node] def wrap_node(mutant) s(:begin, mutant, s(:send, nil, :memoize, s(:args, s(:sym, name)))) end diff --git a/lib/mutant/transform.rb b/lib/mutant/transform.rb index a75d6e3e3..7cba92521 100644 --- a/lib/mutant/transform.rb +++ b/lib/mutant/transform.rb @@ -49,9 +49,6 @@ def trace private - # Path representation to error - # - # @return [String] def path trace.map { |error| error.transform.slug }.reject(&:empty?).join('/') end @@ -78,23 +75,6 @@ def slug private - # Make error from curent context - # - # @param [Error, nil] cause - # original error, if any - # - # @param [Object] input - # input that ran into the error - # - # @param [String] message - # human readable error message - # - # @param [Transform, nil] - # transform that generated the error from input - # - # @return [Error] - # - # ignore :reek:LongParameterList def error(cause: nil, input:, message: nil) Error.new( cause: cause, @@ -104,42 +84,18 @@ def error(cause: nil, input:, message: nil) ) end - # Lift error - # - # @param [Error] - # - # @return [Error] def lift_error(error) error.with(transform: self) end - # Wrap error - # - # @param [Error] - # - # @return [Error] def wrap_error(error) error(cause: error, input: error.input) end - # Create failure - # - # @param [Object] value - # - # @return [Either::Left] - # - # ignore :reek:UtilityFunction def failure(value) Either::Left.new(value) end - # Create success - # - # @param [Object] value - # - # @return [Either::Right] - # - # ignore :reek:UtilityFunction def success(value) Either::Right.new(value) end @@ -268,14 +224,6 @@ def apply(input) private - # Transform array - # - # @param [Array] input - # - # @return [Either] - # - # ignore :reek:NestedIterators - # # rubocop:disable Metrics/MethodLength def run(input) output = [] @@ -357,31 +305,16 @@ def apply(input) private - # Transform hash - # - # @param [Hash] input - # - # @return [Either] def transform(input) transform_required(input).bind do |required| transform_optional(input).fmap(&required.method(:merge)) end end - # Transform required keys - # - # @param [Hash] input - # - # @return [Either] def transform_required(input) transform_keys(required, input) end - # Transform optional keys - # - # @param [Hash] input - # - # @return [Either] def transform_optional(input) transform_keys( optional.select { |key| input.key?(key.value) }, @@ -389,13 +322,6 @@ def transform_optional(input) ) end - # Transform keys - # - # @param [Array] keys - # @param [Hash] input - # - # @return [Either] - # # ignore :reek:NestedIterators # # rubocop:disable Metrics/MethodLength @@ -415,24 +341,12 @@ def transform_keys(keys, input) end # rubocop:enable Metrics/MethodLength - # Coerce key value under key specific transformer - # - # @param [Hash::Key] key - # @param [Hash] input - # - # @return [Either] def coerce_key(key, input) key.apply(input.fetch(key.value)).lmap do |error| error(input: input, cause: error) end end - # Reject unexpected keys - # - # @param [Hash] - # - # @return [Either] - # # rubocop:disable Metrics/MethodLength def reject_keys(input) keys = input.keys @@ -452,17 +366,11 @@ def reject_keys(input) end # rubocop:enable Metrics/MethodLength - # Key values allowed to be present - # - # @return [Array] def allowed_keys required_keys + optional.map(&:value) end memoize :allowed_keys - # Key values required to be present - # - # @return [Array] def required_keys required.map(&:value) end diff --git a/lib/mutant/warnings.rb b/lib/mutant/warnings.rb index 37ddfa1fc..65698ef90 100644 --- a/lib/mutant/warnings.rb +++ b/lib/mutant/warnings.rb @@ -92,9 +92,6 @@ def call private - # Hook called when capturing a warning - # - # @return [undefined] def capture(*arguments) if @disabled @original.call(*arguments) @@ -103,9 +100,6 @@ def capture(*arguments) end end - # Assert warnings capture does not call itself - # - # Its currently not supported nor intended to be supported. def assert_no_recursion fail RecursiveUseError unless @disabled end diff --git a/lib/mutant/zombifier.rb b/lib/mutant/zombifier.rb index feef29188..2a9487bc0 100644 --- a/lib/mutant/zombifier.rb +++ b/lib/mutant/zombifier.rb @@ -42,32 +42,20 @@ def self.call(*args) private - # Original require method + attr_reader :original + private :original # # @return [Method] - attr_reader :original - # Run zombifier - # - # @return [undefined] def call @original = require_highjack.call(method(:require)) require(root_require) end - # Test if logical name is subjected to zombification - # - # @param [String] def include?(logical_name) !@zombified.include?(logical_name) && includes =~ logical_name end - # Require file in zombie namespace - # - # @param [#to_s] logical_name - # - # @return [Bool] - # true if successful and false if feature already loaded def require(logical_name) logical_name = logical_name.to_s loaded = original.call(logical_name) @@ -77,14 +65,6 @@ def require(logical_name) true end - # Find file by logical path - # - # @param [String] logical_name - # - # @return [File] - # - # @raise [LoadError] - # otherwise def find(logical_name) file_name = "#{logical_name}.rb" @@ -96,13 +76,6 @@ def find(logical_name) fail LoadError, "Cannot find file #{file_name.inspect} in load path" end - # Zombify contents of file - # - # Probably the 2nd valid use of eval ever. (First one is inserting mutants!). - # - # @param [Pathname] source_path - # - # @return [undefined] def zombify(source_path) kernel.eval( Unparser.unparse(namespaced_node(source_path)), @@ -111,11 +84,6 @@ def zombify(source_path) ) end - # Namespaced root node - # - # @param [Pathname] source_path - # - # @return [Parser::AST::Node] def namespaced_node(source_path) s(:module, s(:const, nil, namespace), Unparser.parse(source_path.read)) end diff --git a/mutant.sh b/mutant.sh new file mode 100755 index 000000000..2fe586d16 --- /dev/null +++ b/mutant.sh @@ -0,0 +1,12 @@ +#/usr/bin/bash -ex + +bundle exec mutant \ + --since HEAD~1 \ + --zombie \ + --ignore-subject Mutant::CLI#add_debug_options \ + --ignore-subject Mutant::Mutator::Node::Argument#skip? \ + --ignore-subject Mutant::Mutator::Node::ProcargZero#dispatch \ + --ignore-subject Mutant::Mutator::Node::When#mutate_conditions \ + --ignore-subject Mutant::Zombifier#call \ + -- \ + 'Mutant*'