-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from g-Off/swift-5
Swift 5
- Loading branch information
Showing
34 changed files
with
315 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.build | ||
/Packages | ||
/*.xcodeproj | ||
.swiftpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM swift:4.2.1 | ||
COPY Package.swift ./Package.swift | ||
COPY Sources ./Sources | ||
COPY Tests ./Tests | ||
RUN swift test --configuration debug |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,47 @@ | ||
// swift-tools-version:4.2 | ||
// swift-tools-version:5.0 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "stringray", | ||
platforms: [ | ||
.macOS(.v10_14) | ||
], | ||
products: [ | ||
.executable( | ||
name: "stringray", | ||
targets: ["stringray"] | ||
), | ||
.library( | ||
name: "RayGun", | ||
targets: ["RayGun"] | ||
) | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/jpsim/Yams.git", from: "1.0.1"), | ||
.package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.5.0"), | ||
.package(url: "https://github.com/g-Off/XcodeProject.git", from: "0.4.0"), | ||
.package(url: "https://github.com/g-Off/CommandRegistry.git", .branch("master")) | ||
.package(url: "https://github.com/g-Off/XcodeProject.git", from: "0.5.0-alpha.3"), | ||
.package(url: "https://github.com/g-Off/CommandRegistry.git", from: "0.1.0"), | ||
.package(url: "https://github.com/apple/swift-package-manager.git", from: "0.3.0") | ||
], | ||
targets: [ | ||
.target( | ||
name: "stringray", | ||
dependencies: [ | ||
"Yams", | ||
"CommandRegistry", | ||
"RayGun", | ||
"SwiftyTextTable", | ||
"XcodeProject", | ||
"CommandRegistry" | ||
"Utility", | ||
"Yams", | ||
] | ||
), | ||
.target( | ||
name: "RayGun", | ||
dependencies: [ | ||
] | ||
), | ||
.testTarget( | ||
name: "stringrayTests", | ||
dependencies: ["stringray"]), | ||
dependencies: ["RayGun"]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// LintRule.swift | ||
// stringray | ||
// | ||
// Created by Geoffrey Foster on 2018-11-07. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol LintRule { | ||
var info: RuleInfo { get } | ||
func scan(table: StringsTable, url: Foundation.URL, config: Linter.Config.Rule?) throws -> [LintRuleViolation] | ||
} | ||
|
||
public struct RuleInfo { | ||
public let identifier: String | ||
public let name: String | ||
public let description: String | ||
public let severity: Severity | ||
} | ||
|
||
public enum Severity: String, CustomStringConvertible, Decodable { | ||
case warning | ||
case error | ||
|
||
public var description: String { | ||
return rawValue | ||
} | ||
} | ||
|
||
public struct LintRuleViolation { | ||
public struct Location: CustomStringConvertible { | ||
public let file: Foundation.URL | ||
public let line: Int? | ||
|
||
public var description: String { | ||
var path = file.lastPathComponent | ||
if let line = line { | ||
path.append(":\(line)") | ||
} | ||
return path | ||
} | ||
} | ||
|
||
public let locale: Locale | ||
public let location: Location | ||
public let severity: Severity | ||
public let reason: String | ||
|
||
public init(locale: Locale, location: Location, severity: Severity, reason: String) { | ||
self.locale = locale | ||
self.location = location | ||
self.severity = severity | ||
self.reason = reason | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// MissingCommentLintRule.swift | ||
// RayGun | ||
// | ||
// Created by Geoffrey Foster on 2019-06-02. | ||
// | ||
|
||
import Foundation | ||
|
||
struct MissingCommentLintRule: LintRule { | ||
let info: RuleInfo = RuleInfo(identifier: "missing_comment", name: "Missing Comment", description: "", severity: .error) | ||
|
||
func scan(table: StringsTable, url: Foundation.URL, config: Linter.Config.Rule?) throws -> [LintRuleViolation] { | ||
var violations: [LintRuleViolation] = [] | ||
let file = Foundation.URL(fileURLWithPath: "\(table.base.identifier).lproj/\(table.name).strings", relativeTo: url) | ||
for entry in table.baseEntries where entry.comment == nil { | ||
let line = entry.location?.line | ||
let location = LintRuleViolation.Location(file: file, line: line) | ||
let reason = "Mismatched placeholders \(entry.key)" | ||
let violation = LintRuleViolation(locale: table.base, location: location, severity: config?.severity ?? info.severity, reason: reason) | ||
violations.append(violation) | ||
} | ||
return violations | ||
} | ||
} |
Oops, something went wrong.