Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

danger-swiftlint doesn't warn, while SwiftLint itself does #48

Closed
freak4pc opened this issue Jul 16, 2017 · 16 comments
Closed

danger-swiftlint doesn't warn, while SwiftLint itself does #48

freak4pc opened this issue Jul 16, 2017 · 16 comments

Comments

@freak4pc
Copy link

freak4pc commented Jul 16, 2017

I'm not sure if this is some misconfiguration (mainly due to the fact there's barely any configuration around danger-swiftlint... )

But when SwiftLint runs by itself, i see specifically

Todo Violation: TODOs should be avoided (...). (todo)

But when danger-swiftlint runs in my CI (Buddybuild), it doesn't warn for some odd reason

Installing danger 5.3.3
Fetching danger-swiftlint 0.7.0
Installing danger-swiftlint 0.7.0 with native extensions
Bundle complete! 2 Gemfile dependencies, 22 gems now installed.
Bundled gems are installed into /tmp/sandbox/workspace/vendor/bundle.

Running Danger
Using Command Line: bundle exec danger --dangerfile=Dangerfile

Results:
    Warnings:
    - [ ] Big PR
    - [ ] The `Podfile` was updated

But no specific warnings related to SwiftLint, and I'm not exactly sure why or if I'm missing something.

Gemfile only has danger and danger-swiftlint

The portion of Dangerfile related to SwiftLint is:

# SwiftLint
swiftlint.config_file = '.swiftlint.yml'
swiftlint.binary_path = './Pods/SwiftLint/swiftlint'
swiftlint.lint_files
swiftlint.lint_files inline_mode: true

I'm wondering if this is related to the fact I'm using a pinned version with CocoaPods, but I don't see why that would be an issue 🤔

Appreciate any help on this :)

@freak4pc freak4pc reopened this Jul 16, 2017
@ashfurrow
Copy link
Owner

Hmm, that's an odd one. Sorry you're experiencing this problem. I agree CocoaPods doesn't seem like a likely source of the problem. I'm not sure what's going on here – I'll try to take a look this weekend. If you could reproduce the problem in a test project, that would make debugging the issue a lot easier. Let me know if you make any progress!

@freak4pc
Copy link
Author

Thanks for the reply @ashfurrow :) I'll try digging into it this weekend as well and provide some more feedback

@RishabhTayal
Copy link

I am having this issue as well. In my case I am using multiple swiftlint.lint_files for different project within the workspace. However I don't think that's what causing the issue.

@ashfurrow
Copy link
Owner

Could this be related to #49?

@RishabhTayal
Copy link

I am not getting any error when running swiflint but seems like when running swiftlint command for multiple configuration files doesn't comment on the pr for remaining projects.

@freak4pc
Copy link
Author

freak4pc commented Aug 8, 2017

Still couldn't dive much into this as i'm swamped with work but noticed much of this in my PR logs which is interesting 🤔

It seems as if it's using the swift filenames as folders for some odd reason ...

Also wondering on why it's using @marcelofabri 's user folder... ❓


Using Command Line: bundle exec danger --dangerfile=Dangerfile

fatal error: Could not read configuration file at path '/tmp/sandbox/workspace/TimHortons/SomeSwiftFile.swift/.swiftlint.yml': file /Users/marcelofabri/Westfield/SwiftLint/Source/SwiftLintFramework/Models/Configuration.swift, line 167
/tmp/sandbox/workspace/TimHortons/RBIKit/API/THPayments.swift/.swiftlint.yml:File not found.

fatal error: Could not read configuration file at path '/tmp/sandbox/workspace/TimHortons/SomeSwiftFile.swift/.swiftlint.yml': file /Users/marcelofabri/Westfield/SwiftLint/Source/SwiftLintFramework/Models/Configuration.swift, line 167
/tmp/sandbox/workspace/TimHortons/RBIKit/Common/RBIUserProfile.swift/.swiftlint.yml:File not found.

fatal error: Could not read configuration file at path '/tmp/sandbox/workspace/TimHortons/RBIKit/Models/THGiftCard.swift/.swiftlint.yml': file /Users/marcelofabri/Westfield/SwiftLint/Source/SwiftLintFramework/Models/Configuration.swift, line 167
/tmp/sandbox/workspace/TimHortons/SomeSwiftFile.swift/.swiftlint.yml:File not found.

fatal error: Could not read configuration file at path '/tmp/sandbox/workspace/TimHortons/SomeSwiftFile.swift/.swiftlint.yml': file /Users/marcelofabri/Westfield/SwiftLint/Source/SwiftLintFramework/Models/Configuration.swift, line 167
/tmp/sandbox/workspace/TimHortons/SomeSwiftFile.swift/.swiftlint.yml:File not found.

/tmp/sandbox/workspace/TimHortons/SomeSwiftFile.swift/.swiftlint.yml:File not found.

@marcelofabri
Copy link
Collaborator

That's just a side effect on how fatalError works in Swift. It uses #file, which is resolved in compilation time. And you see that path because the CocoaPods build was compiled on my machine.

Note that it's only the path for the Swift file where the fatalError was called. The important part is the message after fatal error:, before file:.

This can be related to #49. I recommend you to update SwiftLint to 0.21.0.

@Sega-Zero
Copy link

Any news on this? swiftlint 0.22.0, still not working

@ashfurrow
Copy link
Owner

Hey, sorry no updates. It would be really helpful if anyone were able to put together a sample project demonstrating the problem, so we can reproduce and debug.

@Sega-Zero
Copy link

Will try to create a sample repo asap

@Sega-Zero
Copy link

Take a look at Sega-Zero/danger-sample#1
It should fail, but it shows all green.
Right now I have to use this Dangerfile to make things working, but that's not that comfortable

warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"

message("Started linting a PR " + github.pr_title)
system("./project/Pods/SwiftLint/swiftlint --strict --quiet --config .swiftlint.yml --path ./project/" )
fail("Linting failed") if $?.exitstatus != 0

message("I'm done with this PR")

@ashfurrow ashfurrow mentioned this issue Oct 7, 2017
ashfurrow added a commit that referenced this issue Oct 7, 2017
@ashfurrow
Copy link
Owner

Okay, thanks! I've used your project to reproduce the bug – I think it's related to the config file paths not being expanded properly. I've fixed the bug and introduced a new verbose logging mode in #60, which has been released as danger-swift 0.10.1. If you could, please update to this version and enable verbose logging so we can get a better idea of what's going on.

@heidiproske
Copy link

heidiproske commented Dec 1, 2017

hey @ashfurrow I was taking a look at @Sega-Zero's code snippet from Oct 7 while I was trying to debug something with danger local. If I use his snippet it lints all files (and I get the results I want).

But when I run danger-swiftlint it only lints modified/added files for the PR.

My Dangerfile looks like this:

# Run SwiftLint
swiftlint.config_file = './.swiftlint.yml'
swiftlint.verbose = true
swiftlint.lint_files fail_on_error: false
swiftlint.lint_files inline_mode: true

Is there a way for danger-swiftlint to show all outstanding warnings in my project on every PR - not just the files I touched? (I did try adding the included: section to my .swiftlint.yml). I can't see anything in the docs.

(Using danger-swiftlint (0.11.0) and SwiftLint 0.24.0)

@Sega-Zero
Copy link

@heidiproske, @ashfurrow answered the same question from me.

@omirho
Copy link
Collaborator

omirho commented Mar 26, 2018

This seems to have been fixed with #60
Closing.

@omirho omirho closed this as completed Mar 26, 2018
@Sega-Zero
Copy link

This is not really fixed, but explained in the link I mentioned above. It is by design.
Those who came here for a same question, I recommend to switch to danger-swiftlint written in swift. It is great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants