Skip to content

Commit

Permalink
Add package ACL (#5559)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny committed May 4, 2024
1 parent 4a72167 commit d734022
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Source/SwiftLintCore/Models/AccessControlLevel.swift
Expand Up @@ -8,6 +8,8 @@ public enum AccessControlLevel: String, CustomStringConvertible {
case `fileprivate` = "source.lang.swift.accessibility.fileprivate"
/// Accessible by the declaration's same module, or modules importing it with the `@testable` attribute.
case `internal` = "source.lang.swift.accessibility.internal"
/// Accessible by all the modules defined in the same Swift package.
case `package` = "source.lang.swift.accessibility.package"
/// Accessible by the declaration's same program.
case `public` = "source.lang.swift.accessibility.public"
/// Accessible and customizable (via subclassing or overrides) by the declaration's same program.
Expand All @@ -21,6 +23,7 @@ public enum AccessControlLevel: String, CustomStringConvertible {
case "private": self = .private
case "fileprivate": self = .fileprivate
case "internal": self = .internal
case "package": self = .package
case "public": self = .public
case "open": self = .open
default: return nil
Expand All @@ -39,6 +42,7 @@ public enum AccessControlLevel: String, CustomStringConvertible {
case .private: return "private"
case .fileprivate: return "fileprivate"
case .internal: return "internal"
case .package: return "package"
case .public: return "public"
case .open: return "open"
}
Expand All @@ -56,8 +60,9 @@ extension AccessControlLevel: Comparable {
case .private: return 1
case .fileprivate: return 2
case .internal: return 3
case .public: return 4
case .open: return 5
case .package: return 4
case .public: return 5
case .open: return 6
}
}

Expand Down
4 changes: 3 additions & 1 deletion Tests/SwiftLintFrameworkTests/AccessControlLevelTests.swift
Expand Up @@ -6,14 +6,16 @@ final class AccessControlLevelTests: SwiftLintTestCase {
XCTAssertEqual(AccessControlLevel.private.description, "private")
XCTAssertEqual(AccessControlLevel.fileprivate.description, "fileprivate")
XCTAssertEqual(AccessControlLevel.internal.description, "internal")
XCTAssertEqual(AccessControlLevel.package.description, "package")
XCTAssertEqual(AccessControlLevel.public.description, "public")
XCTAssertEqual(AccessControlLevel.open.description, "open")
}

func testPriority() {
XCTAssertLessThan(AccessControlLevel.private, .fileprivate)
XCTAssertLessThan(AccessControlLevel.fileprivate, .internal)
XCTAssertLessThan(AccessControlLevel.internal, .public)
XCTAssertLessThan(AccessControlLevel.internal, .package)
XCTAssertLessThan(AccessControlLevel.package, .public)
XCTAssertLessThan(AccessControlLevel.public, .open)
}
}

0 comments on commit d734022

Please sign in to comment.