mutant icon indicating copy to clipboard operation
mutant copied to clipboard

Allow `mutant:disable` to apply to inline macros and visibility modifiers

Open dgollahon opened this issue 2 years ago • 1 comments

class MutantExample
  private

  # mutant:disable
  public def demo
    {}.freeze
  end
end
RSpec.describe MutantExample do
  it 'is a hash' do
    expect(described_class.new.demo).to be_a(Hash)
  end
end

The above produces an alive mutation (see #1398) but if I change the public modifier to not be inline, the mutant:disable does work:

class MutantExample
  private

  # mutant:disable
  def demo
    {}.freeze
  end
  public :demo
end

Note that I care about this beyond just private, protected, and public. I have some macros (like memoize) where I would prefer to use it in an inline fashion rather than repeating the name of the method below the method in the macro.

dgollahon avatar Aug 03 '23 19:08 dgollahon

I have a related experience where inline # mutant:disable before a sorbet signature sig { ... } does not attach to the method properly. I think a solution that ensures that an inline disable binds to the next subject in the source file would solve both our issues here. Backchanneling with @mbj about this and I think we're on the same page here.

jmileham avatar May 07 '25 01:05 jmileham