Skip to content

SwiftLint does not recognise the file path correctly #641

Open
@taise-hikawa

Description

@taise-hikawa

environment

mac os: 15.2
version: 3.21.1

description

I encountered an issue where, if the Dangerfile is not located in the root directory, SwiftLint does not correctly recognize the file paths. After reviewing the library's code, it seems there is no option to change the working directory for executing the SwiftLint command.

steps to reproduce

example: https://github.com/taise-hikawa/danger-sample
if you add SwiftLint.lint(inline: true, configFile: "../.swiftlint.yml") to Dangerfile.swift and try following command at ./LocalPackage directory, you can get following error messages.
swift run danger-swift pr https://github.com/taise-hikawa/danger-sample/pull/2 --verbose

error messages

Could not read contents of `/Users/hikawataisei/Desktop/code/private/danger-sample/LocalPackage/LocalPackage/Dangerfile.swift`
Could not read contents of `/Users/hikawataisei/Desktop/code/private/danger-sample/LocalPackage/LocalPackage/Package.swift`
Could not read contents of `/Users/hikawataisei/Desktop/code/private/danger-sample/LocalPackage/LocalPackage/Sources/DangerTarget/Fake.swift`
Could not read contents of `/Users/hikawataisei/Desktop/code/private/danger-sample/LocalPackage/LocalPackage/Sources/Hoge/HogeView.swift`
Could not read contents of `/Users/hikawataisei/Desktop/code/private/danger-sample/LocalPackage/danger-sample/DangerSampleApp.swift`

It appears this might be a bug in the Danger library. Could you please look into this? Let me know if you need any further details.
Thank you for your time and help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions