Skip to content

Commit

Permalink
Don't run Flog on spec/test files
Browse files Browse the repository at this point in the history
It creates a lot of noise.
Generally, spec and test files are less concise due to verbosity of
them.
  • Loading branch information
gylaz committed Aug 17, 2018
1 parent de2569d commit 8cd270a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
4 changes: 4 additions & 0 deletions app/models/linter/flog.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module Linter
class Flog < Base
FILE_REGEXP = /.+\.r(b|ake)\z/

def file_included?(commit_file)
commit_file.filename !~ /^(spec|test)\//
end
end
end
34 changes: 26 additions & 8 deletions spec/models/linter/flog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,32 @@
let(:not_lintable_files) { %w(foo.js) }
end

describe "#file_included?" do
context "with test or spec file" do
it "returns false" do
spec_file = build_commit_file(filename: "spec/models/user_spec.rb")
test_file = build_commit_file(filename: "spec/models/user_spec.rb")
linter = build_linter

expect(linter.file_included?(spec_file)).to eq false
expect(linter.file_included?(test_file)).to eq false
end
end

context "with any other ruby file" do
it "returns true" do
file1 = build_commit_file(filename: "app/models/user.rb")
file2 = build_commit_file(filename: "lib/tasks/work.rake")
file3 = build_commit_file(filename: "app.rb")
linter = build_linter

expect(linter.file_included?(file1)).to eq true
expect(linter.file_included?(file2)).to eq true
expect(linter.file_included?(file3)).to eq true
end
end
end

describe "#enabled?" do
context "when Flog linting is enabled" do
it "returns true" do
Expand All @@ -28,14 +54,6 @@
end
end

describe "#file_included?" do
it "returns true" do
linter = build_linter

expect(linter.file_included?).to be(true)
end
end

describe "#file_review" do
it "schedules a file review" do
commit_file = build_commit_file(filename: "lib/foo.rb")
Expand Down

0 comments on commit 8cd270a

Please sign in to comment.