style: remove RSpec/ExampleLength violations
This commit is contained in:
parent
cb4154c5a1
commit
3e00b3ea28
@ -6,6 +6,10 @@ require "rubocops/patches"
|
|||||||
describe RuboCop::Cop::FormulaAudit::Patches do
|
describe RuboCop::Cop::FormulaAudit::Patches do
|
||||||
subject(:cop) { described_class.new }
|
subject(:cop) { described_class.new }
|
||||||
|
|
||||||
|
def expect_offense_hash(message:, severity:, line:, column:, source:)
|
||||||
|
[{ message: message, severity: severity, line: line, column: column, source: source }]
|
||||||
|
end
|
||||||
|
|
||||||
context "when auditing legacy patches" do
|
context "when auditing legacy patches" do
|
||||||
it "reports no offenses if there is no legacy patch" do
|
it "reports no offenses if there is no legacy patch" do
|
||||||
expect_no_offenses(<<~RUBY)
|
expect_no_offenses(<<~RUBY)
|
||||||
@ -49,63 +53,35 @@ describe RuboCop::Cop::FormulaAudit::Patches do
|
|||||||
EOS
|
EOS
|
||||||
|
|
||||||
expected_offense = if patch_url.include?("/raw.github.com/")
|
expected_offense = if patch_url.include?("/raw.github.com/")
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 4, source: source
|
||||||
<<~EOS.chomp,
|
GitHub/Gist patches should specify a revision:
|
||||||
GitHub/Gist patches should specify a revision:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 4,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.include?("macports/trunk")
|
elsif patch_url.include?("macports/trunk")
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 4, source: source
|
||||||
<<~EOS.chomp,
|
MacPorts patches should specify a revision instead of trunk:
|
||||||
MacPorts patches should specify a revision instead of trunk:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 4,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.start_with?("http://trac.macports.org")
|
elsif patch_url.start_with?("http://trac.macports.org")
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 4, source: source
|
||||||
<<~EOS.chomp,
|
Patches from MacPorts Trac should be https://, not http:
|
||||||
Patches from MacPorts Trac should be https://, not http:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 4,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.start_with?("http://bugs.debian.org")
|
elsif patch_url.start_with?("http://bugs.debian.org")
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 4, source: source
|
||||||
<<~EOS.chomp,
|
Patches from Debian should be https://, not http:
|
||||||
Patches from Debian should be https://, not http:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 4,
|
|
||||||
source: source }]
|
|
||||||
# rubocop:disable Layout/LineLength
|
# rubocop:disable Layout/LineLength
|
||||||
elsif patch_url.match?(%r{https?://patch-diff\.githubusercontent\.com/raw/(.+)/(.+)/pull/(.+)\.(?:diff|patch)})
|
elsif patch_url.match?(%r{https?://patch-diff\.githubusercontent\.com/raw/(.+)/(.+)/pull/(.+)\.(?:diff|patch)})
|
||||||
# rubocop:enable Layout/LineLength
|
# rubocop:enable Layout/LineLength
|
||||||
[{ message: "Use a commit hash URL rather than patch-diff: #{patch_url}",
|
expect_offense_hash message: "Use a commit hash URL rather than patch-diff: #{patch_url}",
|
||||||
severity: :convention,
|
severity: :convention, line: 5, column: 4, source: source
|
||||||
line: 5,
|
|
||||||
column: 4,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.match?(%r{https?://github\.com/.+/.+/(?:commit|pull)/[a-fA-F0-9]*.(?:patch|diff)})
|
elsif patch_url.match?(%r{https?://github\.com/.+/.+/(?:commit|pull)/[a-fA-F0-9]*.(?:patch|diff)})
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS, severity: :convention, line: 5, column: 4, source: source
|
||||||
<<~EOS,
|
GitHub patches should use the full_index parameter:
|
||||||
GitHub patches should use the full_index parameter:
|
#{patch_url}?full_index=1
|
||||||
#{patch_url}?full_index=1
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 4,
|
|
||||||
source: source }]
|
|
||||||
end
|
end
|
||||||
expected_offense.zip([inspect_source(source).last]).each do |expected, actual|
|
expected_offense.zip([inspect_source(source).last]).each do |expected, actual|
|
||||||
expect(actual.message).to eq(expected[:message])
|
expect(actual.message).to eq(expected[:message])
|
||||||
@ -228,85 +204,48 @@ describe RuboCop::Cop::FormulaAudit::Patches do
|
|||||||
RUBY
|
RUBY
|
||||||
|
|
||||||
expected_offense = if patch_url.include?("/raw.github.com/")
|
expected_offense = if patch_url.include?("/raw.github.com/")
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 8, source: source
|
||||||
<<~EOS.chomp,
|
GitHub/Gist patches should specify a revision:
|
||||||
GitHub/Gist patches should specify a revision:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 8,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.include?("macports/trunk")
|
elsif patch_url.include?("macports/trunk")
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 8, source: source
|
||||||
<<~EOS.chomp,
|
MacPorts patches should specify a revision instead of trunk:
|
||||||
MacPorts patches should specify a revision instead of trunk:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 8,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.start_with?("http://trac.macports.org")
|
elsif patch_url.start_with?("http://trac.macports.org")
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 8, source: source
|
||||||
<<~EOS.chomp,
|
Patches from MacPorts Trac should be https://, not http:
|
||||||
Patches from MacPorts Trac should be https://, not http:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 8,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.start_with?("http://bugs.debian.org")
|
elsif patch_url.start_with?("http://bugs.debian.org")
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 8, source: source
|
||||||
<<~EOS.chomp,
|
Patches from Debian should be https://, not http:
|
||||||
Patches from Debian should be https://, not http:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 8,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.match?(%r{https://github.com/[^/]*/[^/]*/pull})
|
elsif patch_url.match?(%r{https://github.com/[^/]*/[^/]*/pull})
|
||||||
[{ message: "Use a commit hash URL rather than an unstable pull request URL: #{patch_url}",
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 8, source: source
|
||||||
severity: :convention,
|
Use a commit hash URL rather than an unstable pull request URL: #{patch_url}
|
||||||
line: 5,
|
EOS
|
||||||
column: 8,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.match?(%r{.*gitlab.*/merge_request.*})
|
elsif patch_url.match?(%r{.*gitlab.*/merge_request.*})
|
||||||
[{ message: "Use a commit hash URL rather than an unstable merge request URL: #{patch_url}",
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 8, source: source
|
||||||
severity: :convention,
|
Use a commit hash URL rather than an unstable merge request URL: #{patch_url}
|
||||||
line: 5,
|
EOS
|
||||||
column: 8,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.match?(%r{https://github.com/[^/]*/[^/]*/commit/})
|
elsif patch_url.match?(%r{https://github.com/[^/]*/[^/]*/commit/})
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 8, source: source
|
||||||
<<~EOS.chomp,
|
GitHub patches should end with .patch, not .diff:
|
||||||
GitHub patches should end with .patch, not .diff:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 8,
|
|
||||||
source: source }]
|
|
||||||
elsif patch_url.match?(%r{.*gitlab.*/commit/})
|
elsif patch_url.match?(%r{.*gitlab.*/commit/})
|
||||||
[{ message:
|
expect_offense_hash message: <<~EOS.chomp, severity: :convention, line: 5, column: 8, source: source
|
||||||
<<~EOS.chomp,
|
GitLab patches should end with .patch, not .diff:
|
||||||
GitLab patches should end with .patch, not .diff:
|
#{patch_url}
|
||||||
#{patch_url}
|
EOS
|
||||||
EOS
|
|
||||||
severity: :convention,
|
|
||||||
line: 5,
|
|
||||||
column: 8,
|
|
||||||
source: source }]
|
|
||||||
# rubocop:disable Layout/LineLength
|
# rubocop:disable Layout/LineLength
|
||||||
elsif patch_url.match?(%r{https?://patch-diff\.githubusercontent\.com/raw/(.+)/(.+)/pull/(.+)\.(?:diff|patch)})
|
elsif patch_url.match?(%r{https?://patch-diff\.githubusercontent\.com/raw/(.+)/(.+)/pull/(.+)\.(?:diff|patch)})
|
||||||
# rubocop:enable Layout/LineLength
|
# rubocop:enable Layout/LineLength
|
||||||
[{ message: "Use a commit hash URL rather than patch-diff: #{patch_url}",
|
expect_offense_hash message: "Use a commit hash URL rather than patch-diff: #{patch_url}",
|
||||||
severity: :convention,
|
severity: :convention, line: 5, column: 8, source: source
|
||||||
line: 5,
|
|
||||||
column: 8,
|
|
||||||
source: source }]
|
|
||||||
end
|
end
|
||||||
expected_offense.zip([inspect_source(source).last]).each do |expected, actual|
|
expected_offense.zip([inspect_source(source).last]).each do |expected, actual|
|
||||||
expect(actual.message).to eq(expected[:message])
|
expect(actual.message).to eq(expected[:message])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user