Commit ecd107b5 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix --warnings=+all:PATH not applying to nodoc.

Removed a special case treatment of warnings with PATH from the
implementation of +all warning.  This check only worked for the
Basic warning type but not for the All type, which throws no
exception when setting of warning has no effect.

Removed the "has no effect" exception from the Basic warning type,
as it wass just a little helper notice and not really crucial to
have.

Fixes #462
parent 658c43ab
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ module JsDuck
        # When used with a path_pattern, only add the pattern to the rules
        # where it can have an effect - otherwise we get a warning.
        @warnings.each do |w|
          w.set(enabled, path_pattern, params) unless path_pattern && w.enabled? == enabled
          w.set(enabled, path_pattern, params)
        end
      end

+4 −3
Original line number Diff line number Diff line
@@ -19,9 +19,10 @@ module JsDuck
      # Optionally enables/disables it for files matching a path_pattern.
      def set(enabled, path_pattern=nil, params=[])
        if path_pattern
          if @enabled == enabled
            raise WarnException, "Warning rule '#{enabled ? '+' : '-'}#{@type}:#{path_pattern}' has no effect"
          else
          # When warning is already enabled, enabling a path will have no effect.
          # Similarly when it's disabled, disabling a path has also no effect.
          # Therefore we'll just ignore a setting like that.
          if @enabled != enabled
            @patterns << Regexp.new(Regexp.escape(path_pattern))
          end
        else
+12 −0
Original line number Diff line number Diff line
@@ -124,6 +124,18 @@ describe JsDuck::Warning::Registry do
    end
  end

  describe "after +nodoc(class,public) and -all:blah/" do
    before do
      warnings.set(:nodoc, true, nil, [:class, :public])
      warnings.set(:all, false, "blah/")
    end

    it "has the :nodoc warning disabled for a public class in blah/" do
      warnings.enabled?(:nodoc, "blah/foo.js", [:class, :public]).should == false
    end
  end


  describe "for backwards compatibility" do
    describe ":no_doc warning" do
      before do