-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
file_header rule should trigger on first line if there're no comments #1520
Comments
Do you want to enforce a certain header format? Take a look how SwiftLint itself does it: https://github.com/realm/SwiftLint/blob/master/.swiftlint.yml#L25-L33 |
So I have the header format
But he will often put in the following for files
And this still passes the file_header rule. |
This rule is opt-in, are you sure you've enabled it as well? It should trigger a warning. |
We are using the whitelist_rules and have it listed as one of the rules. And the rule works great at finding inconsistent headers but does nothing when there is no header. |
Can you provide a small example that triggers the issue? I couldn't reproduce it:
import MapKit
import UIKit
opt_in_rules:
- file_header
file_header:
required_pattern: |
\/\/
\/\/ .*?\.swift
\/\/ Project
\/\/
\/\/ Created by .*? on \d{1,2}\/\d{1,2}\/\d{2}\.
\/\/ Copyright © \d{4} Company\. All rights reserved\.
\/\/ |
Maybe the issue is that when there's a comment, the warning is triggered on that line. Otherwise, the warning is only on the file. That could make Xcode behave differently. |
Ahhh that appears to be the issue. Xcode is ditching the warning. Running it from terminal the warning shows up properly. Anyway to fix it for Xcode? |
Not that I'm aware of. But it'd be possible to change the violation to trigger on the first line of the file here: https://github.com/realm/SwiftLint/blob/master/Source/SwiftLintFramework/Rules/FileHeaderRule.swift#L86. Do you want to try that? Otherwise I might be able to take a look later today. |
I'll give it a shot. |
BTW, I just tried on Xcode and I see the warning on the issue navigator, but not on the file editor itself. |
Ok this is fixed in the pull request #1521 please review when you get a chance. Thanks again for the help. |
So I have the file header rule working great with one small problem. One developer is notorious for not having a file header. How can I enforce requiring this?
The text was updated successfully, but these errors were encountered: