diff options
| -rw-r--r-- | Library/Homebrew/rubocops/extend/formula_cop.rb | 5 | ||||
| -rw-r--r-- | Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb | 25 | 
2 files changed, 28 insertions, 2 deletions
| diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb index 4120be6ef..3f70086b3 100644 --- a/Library/Homebrew/rubocops/extend/formula_cop.rb +++ b/Library/Homebrew/rubocops/extend/formula_cop.rb @@ -180,9 +180,10 @@ module RuboCop          node.source_range.source_buffer        end -      # Returns the string representation if node is of type str +      # Returns the string representation if node is of type str(plain) or dstr(interpolated)        def string_content(node) -        node.str_content if node.type == :str +        return node.str_content if node.type == :str +        node.each_child_node(:str).map(&:str_content).join("") if node.type == :dstr        end        # Returns printable component name diff --git a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb index 581667935..432b15e3c 100644 --- a/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/formula_desc_cop_spec.rb @@ -51,6 +51,31 @@ describe RuboCop::Cop::FormulaAuditStrict::Desc do        end      end +    it "When desc is multiline string" do +      source = <<-EOS.undent +        class Foo < Formula +          url 'http://example.com/foo-1.0.tgz' +          desc '#{"bar"*10}'\ +            '#{"foo"*21}' +        end +      EOS + +      msg = <<-EOS.undent +        Description is too long. "name: desc" should be less than 80 characters. +        Length is calculated as Foo + desc. (currently 98) +      EOS +      expected_offenses = [{ message: msg, +                             severity: :convention, +                             line: 3, +                             column: 2, +                             source: source }] + +      inspect_source(cop, source) +      expected_offenses.zip(cop.offenses).each do |expected, actual| +        expect_offense(expected, actual) +      end +    end +      it "When wrong \"command-line\" usage in desc" do        source = <<-EOS.undent          class Foo < Formula | 
