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

Add LowerACLThanParentRule #2136

Merged
merged 1 commit into from
Apr 8, 2018
Merged

Add LowerACLThanParentRule #2136

merged 1 commit into from
Apr 8, 2018

Conversation

keith
Copy link
Collaborator

@keith keith commented Apr 3, 2018

This new rule validates that if a type/function/variable definition has
an ACL specifier, it is more restrictive than the containing body's
level. This is intended to lint a peculiarity of SE-0025 where it is
stated:

The compiler should not warn when a broader level of access control is
used within a type with more restrictive access, such as internal within
a private type. This allows the designer of the type to select the
access they would use were they to make the type more widely accessible.

I think this is an anti-goal because when a type is made more open, it
should be a concious decision at that time to make it public. This is of
course an opt-in rule as well. This also has the added benefit of
linting this compiler bug: https://bugs.swift.org/browse/SR-2925

@keith keith force-pushed the ks/lower-acl branch 2 times, most recently from 90d0b16 to 141dabf Compare April 3, 2018 21:42
@keith
Copy link
Collaborator Author

keith commented Apr 3, 2018

There are 2 cases where I think it could be argued that this is a downside. The first is the required to fix the bug I linked in the description, but if you have this valid definition:

public protocol Foo {}
extension Foo {
    public func bar() {}
}

You would now have to annotate extension with public as well. I don't see this as a major downside, but it isn't a place where they're commonly added.

The other case is with using fileprivate and private interchangeably at the top level. This is currently valid:

private struct Foo {
    fileprivate var bar: String?
}

But this would be required to change to fileprivate struct Foo with this rule. Overall I think this makes this case more clear, but it does require more fileprivate uses. Also in this case you couldn't just omit fileprivate on the property, which you can otherwise.

These are some downsides, but overall I think this would still be worth it for us in particular!

@SwiftLintBot
Copy link

SwiftLintBot commented Apr 3, 2018

5581 Warnings
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Alamofire.swift:44:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Alamofire.swift:52:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Alamofire.swift:61:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Alamofire.swift:81:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Alamofire.swift:86:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Alamofire.swift:99:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:149:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:156:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:163:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:170:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:177:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:187:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:197:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:208:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:222:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:232:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:242:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:252:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/AFError.swift:350:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Notifications.swift:29:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Notifications.swift:48:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:127:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:133:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:161:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:189:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:212:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:238:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:379:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:386:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:416:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:446:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:471:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:499:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:541:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:549:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:557:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Response.swift:565:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:79:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:94:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:125:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:142:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:169:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:191:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:214:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:236:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:256:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:269:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:282:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Result.swift:295:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Request.swift:244:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Request.swift:267:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:114:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:143:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:182:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:217:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:260:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:277:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:289:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:306:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:329:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:354:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:395:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:410:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:432:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:458:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:484:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:515:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:531:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:552:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:579:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:605:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:636:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:652:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:673:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/ResponseSerialization.swift:700:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Timeline.swift:86:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Timeline.swift:111:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:244:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:255:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:294:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:313:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:341:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:372:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:396:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:425:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:425:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:436:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:511:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:536:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:553:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:572:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:608:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:630:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:660:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:689:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:697:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:705:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/SessionDelegate.swift:715:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Validation.swift:37:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Validation.swift:170:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Validation.swift:194:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Validation.swift:208:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Validation.swift:221:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Validation.swift:246:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Validation.swift:274:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Validation.swift:288:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Alamofire: /Users/distiller/project/osscheck/Alamofire/Source/Validation.swift:312:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/FirefoxAccount.swift:220:14: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/FirefoxAccount.swift:221:14: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/FirefoxAccount.swift:222:14: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/FirefoxAccount.swift:239:14: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/FxAPushMessageHandler.swift:258:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/FxAPushMessageHandler.swift:284:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/FxAClient10.swift:90:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/FxAClient10.swift:530:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/FxAClient10.swift:546:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Account/SyncAuthState.swift:46:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Client/Extensions/NSURLExtensionsMailTo.swift:22:5: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Client/Extensions/UIImageViewExtensions.swift:12:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Client/Extensions/UIImageViewExtensions.swift:58:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Client/Application/AppDelegate.swift:25:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Client/Application/AppDelegate.swift:681:10: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ This PR introduced a violation in Firefox: /Users/distiller/project/osscheck/Firefox/Client/Frontend/Browser/DefaultSearchPrefs.swift:18:12: warning: Lower ACL than parent Violation: Ensure definitions have a lower access control level than their enclosing parent (lower_acl_than_parent)
⚠️ Danger found 5581 violations with this PR. Due to GitHub's max issue comment size, the number shown has been truncated to 123.
12 Messages
📖 Linting Aerial with this PR took 0.46s vs 0.51s on master (9% faster)
📖 Linting Alamofire with this PR took 4.12s vs 4.27s on master (3% faster)
📖 Linting Firefox with this PR took 16.66s vs 18.86s on master (11% faster)
📖 Linting Kickstarter with this PR took 23.9s vs 25.28s on master (5% faster)
📖 Linting Moya with this PR took 2.2s vs 2.12s on master (3% slower)
📖 Linting Nimble with this PR took 2.07s vs 2.13s on master (2% faster)
📖 Linting Quick with this PR took 0.61s vs 0.62s on master (1% faster)
📖 Linting Realm with this PR took 4.18s vs 4.04s on master (3% slower)
📖 Linting SourceKitten with this PR took 1.43s vs 1.33s on master (7% slower)
📖 Linting Sourcery with this PR took 5.83s vs 5.67s on master (2% slower)
📖 Linting Swift with this PR took 20.32s vs 23.48s on master (13% faster)
📖 Linting WordPress with this PR took 20.31s vs 23.73s on master (14% faster)

Generated by 🚫 Danger

@marcelofabri
Copy link
Collaborator

@keith Running the unit tests locally should fail on the first time, but update the docs. It shouldn't fail after Rules.md is updated.

@keith
Copy link
Collaborator Author

keith commented Apr 3, 2018

Updated!

@codecov-io
Copy link

codecov-io commented Apr 3, 2018

Codecov Report

Merging #2136 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2136      +/-   ##
==========================================
+ Coverage   89.88%   89.92%   +0.04%     
==========================================
  Files         266      267       +1     
  Lines       15375    15431      +56     
  Branches     1012     1022      +10     
==========================================
+ Hits        13820    13877      +57     
+ Misses       1535     1534       -1     
  Partials       20       20
Impacted Files Coverage Δ
...wiftLintFramework/Rules/LowerACLThanBodyRule.swift 100% <100%> (ø)
...SwiftLintFramework/Models/AccessControlLevel.swift 89.18% <100%> (+5.18%) ⬆️
Tests/SwiftLintFrameworkTests/RulesTests.swift 100% <100%> (ø) ⬆️
...SwiftLintFramework/Extensions/File+SwiftLint.swift 95.27% <0%> (+0.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09bdddc...925fb26. Read the comment docs.

CHANGELOG.md Outdated
@@ -6,6 +6,10 @@

#### Enhancements

* Add `LowerACLThanParent` rule
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @keith, please leave two trailing spaces after the description.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -98,6 +98,10 @@ class RulesTests: XCTestCase {
verifyRule(EmptyParametersRule.description)
}

func testLowerACLThanParent() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include the Linux tests as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

This new rule validates that if a type/function/variable definition has
an ACL specifier, it is more restrictive than the containing body's
level. This is intended to lint a peculiarity of SE-0025 where it is
stated:

> The compiler should not warn when a broader level of access control is
used within a type with more restrictive access, such as internal within
a private type. This allows the designer of the type to select the
access they would use were they to make the type more widely accessible.

I think this is an anti-goal because when a type is made more open, it
should be a concious decision at that time to make it public. This is of
course an opt-in rule as well. This also has the added benefit of
linting this compiler bug: https://bugs.swift.org/browse/SR-2925
@jpsim
Copy link
Collaborator

jpsim commented Apr 8, 2018

Given that this is opt-in, I'm comfortable with the false positives. Nicely implemented @keith!

@jpsim jpsim merged commit 7070c3b into master Apr 8, 2018
@jpsim jpsim deleted the ks/lower-acl branch April 8, 2018 17:44
@keith
Copy link
Collaborator Author

keith commented Apr 8, 2018

Thanks!

@keith keith changed the title Add LowerACLThanBodyRule Add LowerACLThanParentRule Apr 9, 2018
@keith
Copy link
Collaborator Author

keith commented Apr 20, 2018

Follow up to make this a bit more useful #2164

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

Successfully merging this pull request may close these issues.

6 participants