From cf07d433e73d166060c2f6184725a2a7841f57d0 Mon Sep 17 00:00:00 2001 From: Julian Kahnert Date: Fri, 17 Jan 2020 00:11:53 +0100 Subject: [PATCH 1/4] Create release.yml --- .github/workflows/release.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0d94865 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,17 @@ +name: GitHub Release + +on: + push: + tags: + - '*.*.*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 042785ee36ba5bfef04482bae6a9f54e4266af26 Mon Sep 17 00:00:00 2001 From: Julian Kahnert Date: Fri, 17 Jan 2020 13:50:35 +0100 Subject: [PATCH 2/4] log output improved --- Sources/TerminalLog/TerminalLog.swift | 4 +- Sources/chiaLib/API/Chia.swift | 48 ++++++++++++---- Sources/chiaLib/API/ChiaError.swift | 2 +- Sources/chiaLib/API/Language.swift | 2 +- Sources/chiaLib/Internal/CheckProvider.swift | 4 +- .../CheckProviders/LicenseCheck.swift | 9 +-- .../Internal/CheckProviders/ReadmeCheck.swift | 9 +-- .../CheckProviders/SwiftLintCheck.swift | 55 +++++++++++++++++-- Sources/chiaLib/Internal/CheckResult.swift | 19 +++++++ .../chiaLib/Internal/Errors/CheckError.swift | 6 +- 10 files changed, 126 insertions(+), 32 deletions(-) create mode 100644 Sources/chiaLib/Internal/CheckResult.swift diff --git a/Sources/TerminalLog/TerminalLog.swift b/Sources/TerminalLog/TerminalLog.swift index f3c718e..903a499 100644 --- a/Sources/TerminalLog/TerminalLog.swift +++ b/Sources/TerminalLog/TerminalLog.swift @@ -37,7 +37,7 @@ public struct TerminalLog: LogHandler { formedMessage += " -- " + combinedPrettyMetadata! } - print("\(formedMessage, color: getColor(for: level))\n") + print("\(formedMessage, color: getColor(for: level))") } /// Add, remove, or change the logging metadata. @@ -68,7 +68,7 @@ public struct TerminalLog: LogHandler { color = .red case .warning: color = .yellow - case .info: + case .notice: color = .green default: color = .default diff --git a/Sources/chiaLib/API/Chia.swift b/Sources/chiaLib/API/Chia.swift index 8d8f12e..cbaac83 100644 --- a/Sources/chiaLib/API/Chia.swift +++ b/Sources/chiaLib/API/Chia.swift @@ -96,7 +96,7 @@ public struct Chia { public func runChecks() throws { guard let config = self.config, - let projectRootFolder = self.projectRootFolder else { throw CheckError.configNotFound } + let projectRootFolder = self.projectRootFolder else { throw ChiaError.configNotFound } // get project language guard let detectedLanguags = Language.detect(at: projectRootFolder) else { throw LanguageError.languageDetectionFailed } @@ -104,21 +104,28 @@ public struct Chia { // get all check providers for the detected language or generic ones let filteredProviders = Chia.providers.filter { ($0.type == detectedLanguags || $0.type == .generic) && !$0.isPart(of: config.skippedProviders ?? []) } - var noCheckFailed = true + // run all checks + var results = [CheckResult]() for provider in filteredProviders { do { - try perform(provider.run(with: config, at: projectRootFolder), - msg: "Check Failed [\(provider)]", - errorTransform: { .checkFailed($0) }) + + let checkResults = try provider.run(with: config, at: projectRootFolder) + results.append(contentsOf: checkResults) + + } catch CheckError.checkFailed(let info) { + results.append(CheckResult(severity: .error, message: "CheckError: Failed with info: \(info.description)", metadata: ["checkType": .string(String(describing: provider))])) + } catch CheckError.dependencyNotFound(let dependency) { + results.append(CheckResult(severity: .error, message: "CheckError: Dependency '\(dependency)' not found.", metadata: ["checkType": .string(String(describing: provider))])) + } catch CheckError.configPathNotFound(let path) { + results.append(CheckResult(severity: .error, message: "CheckError: Config path invalid: '\(path)'", metadata: ["checkType": .string(String(describing: provider))])) } catch { - logger?.error("\(error)") - noCheckFailed = false + results.append(CheckResult(severity: .error, message: "\(error.localizedDescription)", metadata: ["checkType": .string(String(describing: provider))])) } } - if noCheckFailed { - logger?.info("All checks successful. We used:\n\(filteredProviders)") - } + // log the output of all checks + log(results) + logger?.info("These checks were used:\n\(filteredProviders)") } // MARK: - Helper Function @@ -130,4 +137,25 @@ public struct Chia { } } + private func log(_ results: [CheckResult]) { + + logger?.info("\n\nCheck Results:\n") + let warnings = results.filter { $0.severity == .warning } + for warning in warnings { + logger?.warning("WARNING: \(warning.message)", metadata: warning.metadata) + } + + let errors = results.filter { $0.severity == .error } + for error in errors { + logger?.error("ERROR: \(error.message)", metadata: error.metadata) + } + + if warnings.isEmpty && errors.isEmpty { + logger?.notice("\nAll checks successful.\n") + } else if errors.isEmpty { + logger?.warning("\nFound \(warnings.count) warnings.\n") + } else { + logger?.error("\nFound \(errors.count) errors and \(warnings.count) warnings.\n") + } + } } diff --git a/Sources/chiaLib/API/ChiaError.swift b/Sources/chiaLib/API/ChiaError.swift index 59c6347..1901e60 100644 --- a/Sources/chiaLib/API/ChiaError.swift +++ b/Sources/chiaLib/API/ChiaError.swift @@ -12,5 +12,5 @@ public enum ChiaError: Error { case projectRootNotFound(Error) case yamlReadingError(Error) case yamlDecodingError(Error) - case checkFailed(Error) + case configNotFound } diff --git a/Sources/chiaLib/API/Language.swift b/Sources/chiaLib/API/Language.swift index 5a56368..13185d2 100644 --- a/Sources/chiaLib/API/Language.swift +++ b/Sources/chiaLib/API/Language.swift @@ -17,7 +17,7 @@ public enum Language: String, Equatable, Codable { // case java static func detect(at projectRoot: Folder) -> Language? { - if projectRoot.containsFile(at: "Package.swift") || projectRoot.files.contains(where: { $0.name.hasSuffix("xcodeproj") || $0.name.hasSuffix("xcworkspace") }) { + if projectRoot.containsFile(at: "Package.swift") || projectRoot.subfolders.contains(where: { $0.name.hasSuffix("xcodeproj") || $0.name.hasSuffix("xcworkspace") }) { return .swift } else { return nil diff --git a/Sources/chiaLib/Internal/CheckProvider.swift b/Sources/chiaLib/Internal/CheckProvider.swift index 6d1cf65..ae249f6 100644 --- a/Sources/chiaLib/Internal/CheckProvider.swift +++ b/Sources/chiaLib/Internal/CheckProvider.swift @@ -15,7 +15,7 @@ import ShellOut protocol CheckProvider { static var type: Language { get } - static func run(with config: ChiaConfig, at projectRoot: Folder) throws + static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] } extension CheckProvider { @@ -29,7 +29,7 @@ extension CheckProvider { try shellOut(to: "which", arguments: [binary]) } catch { logger.error("Could not find the dependency '\(binary)'.\n\(error.localizedDescription)") - throw CheckError.dependencyNotFound(binary) + throw CheckError.dependencyNotFound(dependency: binary) } } diff --git a/Sources/chiaLib/Internal/CheckProviders/LicenseCheck.swift b/Sources/chiaLib/Internal/CheckProviders/LicenseCheck.swift index 80d67fb..adbad65 100644 --- a/Sources/chiaLib/Internal/CheckProviders/LicenseCheck.swift +++ b/Sources/chiaLib/Internal/CheckProviders/LicenseCheck.swift @@ -8,11 +8,12 @@ import Files struct LicenseCheck: CheckProvider { + static let type: Language = .generic + private static let missingFileResult = [CheckResult(severity: .error, message: "LICENSE file could not be found.", metadata: nil)] - static func run(with config: ChiaConfig, at projectRoot: Folder) throws { - guard projectRoot.containsFile(at: "LICENSE") else { - throw CheckError.checkFailed(.init(folder: projectRoot, error: nil)) - } + static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] { + let fileMissing = !projectRoot.containsFile(at: "LICENSE") + return fileMissing ? missingFileResult : [] } } diff --git a/Sources/chiaLib/Internal/CheckProviders/ReadmeCheck.swift b/Sources/chiaLib/Internal/CheckProviders/ReadmeCheck.swift index 8e50815..0db656f 100644 --- a/Sources/chiaLib/Internal/CheckProviders/ReadmeCheck.swift +++ b/Sources/chiaLib/Internal/CheckProviders/ReadmeCheck.swift @@ -8,11 +8,12 @@ import Files struct ReadmeCheck: CheckProvider { + static let type: Language = .generic + private static let missingFileResult = [CheckResult(severity: .error, message: "README.md file could not be found.", metadata: nil)] - static func run(with config: ChiaConfig, at projectRoot: Folder) throws { - guard projectRoot.containsFile(at: "README.md") else { - throw CheckError.checkFailed(.init(folder: projectRoot, error: nil)) - } + static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] { + let fileMissing = !projectRoot.containsFile(at: "README.md") + return fileMissing ? missingFileResult : [] } } diff --git a/Sources/chiaLib/Internal/CheckProviders/SwiftLintCheck.swift b/Sources/chiaLib/Internal/CheckProviders/SwiftLintCheck.swift index d3e1c45..5ab00af 100644 --- a/Sources/chiaLib/Internal/CheckProviders/SwiftLintCheck.swift +++ b/Sources/chiaLib/Internal/CheckProviders/SwiftLintCheck.swift @@ -16,7 +16,7 @@ struct SwiftLintCheck: CheckProvider { static let type: Language = .swift private static let configFilename = ".swiftlint.yml" - static func run(with config: ChiaConfig, at projectRoot: Folder) throws { + static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] { // validate if swiftlint exists try canFindDependency(binary: "swiftlint") @@ -27,7 +27,7 @@ struct SwiftLintCheck: CheckProvider { // get local or remote config guard let url = URL(localOrRemotePath: path), - let data = try? Data(contentsOf: url) else { throw CheckError.configNotFound } + let data = try? Data(contentsOf: url) else { throw CheckError.configPathNotFound(path: path) } let swiftlintConfigUrl = projectRoot.url.appendingPathComponent(configFilename) try data.write(to: swiftlintConfigUrl) @@ -43,9 +43,54 @@ struct SwiftLintCheck: CheckProvider { } // run swiftlint - try shellOut(to: "swiftlint", arguments: ["lint", "--quiet", "--reporter json"], at: projectRoot.path) - } catch { - throw CheckError.checkFailed(.init(folder: projectRoot, error: error)) + let jsonOutput = try shellOut(to: "swiftlint", arguments: ["lint", "--quiet", "--reporter json"], at: projectRoot.path) + guard let outputData = jsonOutput.data(using: .utf8) else { + return [CheckResult(severity: .error, message: "Could not create data from SwiftLint output.", metadata: nil)] + } + return parseAndLog(output: outputData) + + } catch let error { + if let shellOutError = error as? ShellOutError, + + let outputData = shellOutError.output.data(using: .utf8) { + return parseAndLog(output: outputData) + + } else { + throw CheckError.checkFailed(with: .init(folder: projectRoot, error: error)) + } + } + } + + private static func parseAndLog(output data: Data) -> [CheckResult] { + + guard let violatons = try? JSONDecoder().decode([Violation].self, from: data) else { + return [CheckResult(severity: .error, message: "Failed to parse violations!", metadata: nil)] + } + + return violatons.map { violation in + CheckResult(severity: violation.severity, + message: "\(violation.type) - \(violation.reason)", + metadata: ["file": .string(violation.file), "line": .stringConvertible(violation.line)]) + } + } +} + +// MARK: - SwiftLint Codable Output + +extension SwiftLintCheck { + struct Violation: Codable { + let character: Int? + let file: String + let line: Int + let reason: String + let ruleID: String + let severity: CheckResult.Severity + let type: String + + enum CodingKeys: String, CodingKey { + case character, file, line, reason + case ruleID = "rule_id" + case severity, type } } } diff --git a/Sources/chiaLib/Internal/CheckResult.swift b/Sources/chiaLib/Internal/CheckResult.swift new file mode 100644 index 0000000..2af9460 --- /dev/null +++ b/Sources/chiaLib/Internal/CheckResult.swift @@ -0,0 +1,19 @@ +// +// CheckResult.swift +// +// +// Created by Julian Kahnert on 17.01.20. +// + +import Logging + +struct CheckResult { + let severity: Severity + let message: String + let metadata: Logger.Metadata? + + enum Severity: String, Codable { + case error = "Error" + case warning = "Warning" + } +} diff --git a/Sources/chiaLib/Internal/Errors/CheckError.swift b/Sources/chiaLib/Internal/Errors/CheckError.swift index db37309..c19c8d5 100644 --- a/Sources/chiaLib/Internal/Errors/CheckError.swift +++ b/Sources/chiaLib/Internal/Errors/CheckError.swift @@ -8,9 +8,9 @@ import Files enum CheckError: Error { - case checkFailed(Info) - case dependencyNotFound(String) - case configNotFound + case checkFailed(with: Info) + case dependencyNotFound(dependency: String) + case configPathNotFound(path: String) } extension CheckError { From f875e4e8bf5d2f7912360c4131d83ac11daf68ce Mon Sep 17 00:00:00 2001 From: Julian Kahnert Date: Fri, 17 Jan 2020 14:07:21 +0100 Subject: [PATCH 3/4] try to get chia config from pwd --- .chia.example.yml | 2 +- Sources/chiaLib/API/Chia.swift | 24 +++++++++++++++----- Sources/chiaLib/Internal/CheckProvider.swift | 1 - 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.chia.example.yml b/.chia.example.yml index 19ab7fe..3ea2386 100644 --- a/.chia.example.yml +++ b/.chia.example.yml @@ -6,5 +6,5 @@ skippedProviders: projectRootAppendix: Null swiftLintConfig: - lintingRulesPath: https://PATH/TO/CONFIG/.swiftlint.yml + # lintingRulesPath: https://PATH/TO/CONFIG/.swiftlint.yml # lintingRulesPath: /LOCAL/PATH/TO/CONFIG/.swiftlint.yml diff --git a/Sources/chiaLib/API/Chia.swift b/Sources/chiaLib/API/Chia.swift index cbaac83..33eb28e 100644 --- a/Sources/chiaLib/API/Chia.swift +++ b/Sources/chiaLib/API/Chia.swift @@ -28,6 +28,9 @@ public struct Chia { /// `Logger` instance that gets injected. private let logger: Logger? + /// Filename that will be searched if no config url will be provided. + private let localConfigFilename = ".chia.yml" + /// `ChiaConfig` that will be save in the `setConfig(from:)` method. private var config: ChiaConfig? @@ -67,8 +70,17 @@ public struct Chia { config = try perform(YAMLDecoder().decode(ChiaConfig.self, from: encodedYAML), msg: "YAML is not valid could not be decoded.", errorTransform: { .yamlDecodingError($0) }) + logger?.info("Using config from: \(url.path)") + } else { - config = ChiaConfig() + if let localConfigString = try? String(contentsOf: Folder.current.url.appendingPathComponent(localConfigFilename)), + let localConfig = try? YAMLDecoder().decode(ChiaConfig.self, from: localConfigString) { + logger?.info("Using local config from: \(localConfigFilename)") + config = localConfig + } else { + logger?.info("Using default chia config.") + config = ChiaConfig() + } } // append project root from config, if needed @@ -103,6 +115,7 @@ public struct Chia { // get all check providers for the detected language or generic ones let filteredProviders = Chia.providers.filter { ($0.type == detectedLanguags || $0.type == .generic) && !$0.isPart(of: config.skippedProviders ?? []) } + logger?.info("These checks will be used:\n\(filteredProviders.map { String(describing: $0) })") // run all checks var results = [CheckResult]() @@ -113,19 +126,18 @@ public struct Chia { results.append(contentsOf: checkResults) } catch CheckError.checkFailed(let info) { - results.append(CheckResult(severity: .error, message: "CheckError: Failed with info: \(info.description)", metadata: ["checkType": .string(String(describing: provider))])) + results.append(CheckResult(severity: .error, message: "CheckError: Failed with info: \(info.description)", metadata: ["checkProvider": .string(String(describing: provider))])) } catch CheckError.dependencyNotFound(let dependency) { - results.append(CheckResult(severity: .error, message: "CheckError: Dependency '\(dependency)' not found.", metadata: ["checkType": .string(String(describing: provider))])) + results.append(CheckResult(severity: .error, message: "CheckError: Dependency '\(dependency)' not found.", metadata: ["checkProvider": .string(String(describing: provider))])) } catch CheckError.configPathNotFound(let path) { - results.append(CheckResult(severity: .error, message: "CheckError: Config path invalid: '\(path)'", metadata: ["checkType": .string(String(describing: provider))])) + results.append(CheckResult(severity: .error, message: "CheckError: Config path invalid: '\(path)'", metadata: ["checkProvider": .string(String(describing: provider))])) } catch { - results.append(CheckResult(severity: .error, message: "\(error.localizedDescription)", metadata: ["checkType": .string(String(describing: provider))])) + results.append(CheckResult(severity: .error, message: "\(error.localizedDescription)", metadata: ["checkProvider": .string(String(describing: provider))])) } } // log the output of all checks log(results) - logger?.info("These checks were used:\n\(filteredProviders)") } // MARK: - Helper Function diff --git a/Sources/chiaLib/Internal/CheckProvider.swift b/Sources/chiaLib/Internal/CheckProvider.swift index ae249f6..6a3eaa1 100644 --- a/Sources/chiaLib/Internal/CheckProvider.swift +++ b/Sources/chiaLib/Internal/CheckProvider.swift @@ -28,7 +28,6 @@ extension CheckProvider { do { try shellOut(to: "which", arguments: [binary]) } catch { - logger.error("Could not find the dependency '\(binary)'.\n\(error.localizedDescription)") throw CheckError.dependencyNotFound(dependency: binary) } } From b8a00b3f9cad99c5fb88e1308cd202e655554a0f Mon Sep 17 00:00:00 2001 From: Julian Kahnert Date: Fri, 17 Jan 2020 14:32:54 +0100 Subject: [PATCH 4/4] readme changes --- README.md | 58 +++++++++++++++++-- Sources/chiaLib/API/Chia.swift | 15 +++++ Sources/chiaLib/Internal/CheckProvider.swift | 9 +-- .../CheckProviders/LicenseCheck.swift | 1 + .../Internal/CheckProviders/ReadmeCheck.swift | 1 + .../CheckProviders/SwiftLintCheck.swift | 6 +- 6 files changed, 74 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9db81ff..4624a96 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,55 @@ -# chia - Check It All +# 🌱 chia - Check It All -## Usage +`chia` is a command line tool that lets you run some checks. +It can be easily integrated into your CI process. +## 🕹 Usage + +You can run `chia` in your terminal, but keep in mind to also install all **required dependencies**. +Otherwise, the check might fail! ```bash # detect language and run all available tests chia +# specify a config for chia (local/remote) +chia --config /PATH/TO/.chia.yml +chia --config https://PATH/TO/.chia.yml + +# only detect and return the language of the project +chia --only-language-detection +``` + +Instead of keeping track of your dependencies, you can use our [Docker Image](https://hub.docker.com/r/worldiety/chia). +It contains all the required binaries and is ready to use: +```bash # run docker container with all dependencies and mount the current folder for analysis -docker run -it -v ${PWD}:/project worldiety/chia:latest +docker run -it -v ${PWD}:/project worldiety/chia:latest +``` + +You can also add this to your [GitLab CI config](https://docs.gitlab.com/ce/ci/yaml/) ... +```yml +... + +stages: + - lint + - build + - deploy + +chia: + stage: lint + image: worldiety/chia:latest + allow_failure: false + script: + - chia + +... ``` +... or use our [:octocat: Github Action](https://github.com/marketplace/actions/github-action-for-chia). -## Installation +## ⌨️🖱Installation + +There are 2 ways to install `chia`. Choose the one that fits your needs. Using [Mint](https://github.com/yonaskolb/mint): ```bash @@ -24,3 +62,15 @@ git clone https://github.com/worldiety/chia && cd chia swift build --configuration release mv `swift build --configuration release --show-bin-path`/chia /usr/local/bin ``` + + +## :octocat: Contributions + +All contributions are welcome! +Feel free to contribute to this project. +Submit pull requests or contribute tutorials - whatever you have to offer, it would be appreciated! + +If a check is missing, the [`CheckProvider`](https://github.com/worldiety/chia/blob/master/Sources/chiaLib/Internal/CheckProvider.swift) is the right places to start. +Just add another implemention and have a look at all the [other checks](https://github.com/worldiety/chia/tree/master/Sources/chiaLib/Internal/CheckProviders). + +If your favorite programming language is missing, have a look at the [`Language`](https://github.com/worldiety/chia/blob/master/Sources/chiaLib/API/Language.swift). diff --git a/Sources/chiaLib/API/Chia.swift b/Sources/chiaLib/API/Chia.swift index 33eb28e..d407022 100644 --- a/Sources/chiaLib/API/Chia.swift +++ b/Sources/chiaLib/API/Chia.swift @@ -11,6 +11,7 @@ import Foundation import FoundationNetworking #endif import Logging +import ShellOut import Yams /// Main part of `Chia`. @@ -122,6 +123,12 @@ public struct Chia { for provider in filteredProviders { do { + // validate if all dependencies (e.g. "swiftlint") exist + for dependency in provider.dependencies { + try canFindDependency(binary: dependency) + } + + // run the check let checkResults = try provider.run(with: config, at: projectRootFolder) results.append(contentsOf: checkResults) @@ -149,6 +156,14 @@ public struct Chia { } } + private func canFindDependency(binary: String) throws { + do { + try shellOut(to: "which", arguments: [binary]) + } catch { + throw CheckError.dependencyNotFound(dependency: binary) + } + } + private func log(_ results: [CheckResult]) { logger?.info("\n\nCheck Results:\n") diff --git a/Sources/chiaLib/Internal/CheckProvider.swift b/Sources/chiaLib/Internal/CheckProvider.swift index 6a3eaa1..fc3ee67 100644 --- a/Sources/chiaLib/Internal/CheckProvider.swift +++ b/Sources/chiaLib/Internal/CheckProvider.swift @@ -15,6 +15,7 @@ import ShellOut protocol CheckProvider { static var type: Language { get } + static var dependencies: [String] { get } static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] } @@ -24,14 +25,6 @@ extension CheckProvider { Logger(label: "CheckProvider") } - static func canFindDependency(binary: String) throws { - do { - try shellOut(to: "which", arguments: [binary]) - } catch { - throw CheckError.dependencyNotFound(dependency: binary) - } - } - static func isPart(of providers: [String]) -> Bool { let selfDescription = String(describing: Self.self).lowercased() return providers.contains { selfDescription.contains($0.lowercased()) } diff --git a/Sources/chiaLib/Internal/CheckProviders/LicenseCheck.swift b/Sources/chiaLib/Internal/CheckProviders/LicenseCheck.swift index adbad65..d179d74 100644 --- a/Sources/chiaLib/Internal/CheckProviders/LicenseCheck.swift +++ b/Sources/chiaLib/Internal/CheckProviders/LicenseCheck.swift @@ -10,6 +10,7 @@ import Files struct LicenseCheck: CheckProvider { static let type: Language = .generic + static let dependencies: [String] = [] private static let missingFileResult = [CheckResult(severity: .error, message: "LICENSE file could not be found.", metadata: nil)] static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] { diff --git a/Sources/chiaLib/Internal/CheckProviders/ReadmeCheck.swift b/Sources/chiaLib/Internal/CheckProviders/ReadmeCheck.swift index 0db656f..545e126 100644 --- a/Sources/chiaLib/Internal/CheckProviders/ReadmeCheck.swift +++ b/Sources/chiaLib/Internal/CheckProviders/ReadmeCheck.swift @@ -10,6 +10,7 @@ import Files struct ReadmeCheck: CheckProvider { static let type: Language = .generic + static let dependencies: [String] = [] private static let missingFileResult = [CheckResult(severity: .error, message: "README.md file could not be found.", metadata: nil)] static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] { diff --git a/Sources/chiaLib/Internal/CheckProviders/SwiftLintCheck.swift b/Sources/chiaLib/Internal/CheckProviders/SwiftLintCheck.swift index 5ab00af..1dfeed0 100644 --- a/Sources/chiaLib/Internal/CheckProviders/SwiftLintCheck.swift +++ b/Sources/chiaLib/Internal/CheckProviders/SwiftLintCheck.swift @@ -14,12 +14,10 @@ import ShellOut struct SwiftLintCheck: CheckProvider { static let type: Language = .swift - + static let dependencies: [String] = ["swiftlint"] private static let configFilename = ".swiftlint.yml" - static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] { - // validate if swiftlint exists - try canFindDependency(binary: "swiftlint") + static func run(with config: ChiaConfig, at projectRoot: Folder) throws -> [CheckResult] { // get config, if not already exists var customSwiftLintConfigUrl: URL?