Skip to content

Commit

Permalink
Ignore files with extensions other than .cr
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Mar 9, 2024
1 parent a2c9aa6 commit a661cf1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions spec/ameba/rule/lint/spec_filename_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ module Ameba::Rule::Lint
expect_no_issues subject, code: "", path: "src/spec/foo/bar.cr"
end

it "passes if file extension is not `.cr`" do
expect_no_issues subject, code: "", path: "spec/foo.json"
expect_no_issues subject, code: "", path: "spec/foo/bar.json"
end

it "passes if filename is correct" do
expect_no_issues subject, code: "", path: "spec/foo_spec.cr"
expect_no_issues subject, code: "", path: "spec/foo/bar_spec.cr"
Expand Down
4 changes: 3 additions & 1 deletion src/ameba/rule/lint/spec_filename.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ module Ameba::Rule::Lint
name = path_.stem
path = path_.to_s

# check files only within spec/ directory
# check only files within spec/ directory
return unless path.starts_with?("spec/")
# check only files with `.cr` extension
return unless path.ends_with?(".cr")
# ignore files having `_spec` suffix
return if name.ends_with?("_spec")

Expand Down

0 comments on commit a661cf1

Please sign in to comment.