Skip to content

Commit

Permalink
Adjust Dangerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
dogo committed Sep 22, 2024
1 parent 004f883 commit 08df02d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@ warn("PR is classed as Work in Progress") if github.pr_title.include?("WIP")
warn("Big PR - #{git.lines_of_code} lines of code") if git.lines_of_code > 150

# Ensure testing shortcuts (fdescribe, fit) aren't accidentally merged into master
fail("fdescribe found in tests") if `grep -r fdescribe specs/ `.length > 1
fail("fit found in tests") if `grep -r fit specs/ `.length > 1
fail("fdescribe found in tests") if `grep -r fdescribe Tests/ `.length > 1
fail("fit found in tests") if `grep -r fit Tests/ `.length > 1

# Define a method to handle directory linting
def lint_directory(directory, config_file)
Dir.chdir(directory) do
message("Linting directory: #{directory}")
swift_files = Dir.glob("#{directory}/**/*.swift")
message("Files in the directory: #{swift_files}")

# Ensure there are Swift files in the directory before running SwiftLint
if swift_files.empty?
warn("No Swift files found in #{directory}")
else
# Run SwiftLint for the entire directory
swiftlint.directory = directory
swiftlint.config_file = config_file
swiftlint.lint_files(fail_on_error: true)
swiftlint.lint(fail_on_error: true)
end
end

# Lint Sources directory
lint_directory('Sources', '.swiftlint.yml')
lint_directory('Sources', File.join(Dir.pwd, '.swiftlint.yml'))

# Lint Tests directory
lint_directory('Tests', '.swiftlint.yml')
lint_directory('Tests', File.join(Dir.pwd, '.swiftlint.yml'))

0 comments on commit 08df02d

Please sign in to comment.