diff --git a/.gitignore b/.gitignore index 0e11e71..81b332f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ /*.xcodeproj xcuserdata/ /AnyLintTempTests +.codacy-coverage +*.lcov +codacy-coverage.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 82d0bfe..b42f7fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,5 +31,13 @@ If needed, pluralize to `Tasks`, `PRs` or `Authors` and list multiple entries se ### Security - None. +## [0.1.1] - 2020-03-23 +### Added +- Added two simple lint check examples in first code sample in README. (Thanks for the pointer, [Dave Verwer](https://github.com/daveverwer)!) + Author: [Cihat Gündüz](https://github.com/Jeehut) +### Changed +- Changed `CheckInfo` id casing convention from snake_case to UpperCamelCase in `blank` template. + Author: [Cihat Gündüz](https://github.com/Jeehut) + ## [0.1.0] - 2020-03-22 Initial public release. diff --git a/Formula/anylint.rb b/Formula/anylint.rb index d6f8682..9ba0049 100644 --- a/Formula/anylint.rb +++ b/Formula/anylint.rb @@ -1,7 +1,7 @@ class Anylint < Formula desc "Lint anything by combining the power of Swift & regular expressions" homepage "https://github.com/Flinesoft/AnyLint" - url "https://github.com/Flinesoft/AnyLint.git", :tag => "0.1.0", :revision => "?" + url "https://github.com/Flinesoft/AnyLint.git", :tag => "0.1.0", :revision => "25fec7dd29d86f0ef97fc2dddcd41d2576d9570c" head "https://github.com/Flinesoft/AnyLint.git" depends_on :xcode => ["11.3", :build] diff --git a/Logo.png b/Logo.png new file mode 100644 index 0000000..c31cac9 Binary files /dev/null and b/Logo.png differ diff --git a/README.md b/README.md index 2242a9f..ced2f50 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +

+ +

+

Coverage - Version: 0.1.0 + Version: 0.1.1 0.1.0 +import AnyLint // @Flinesoft ~> 0.1.1 // MARK: - Variables -// some example variables +let readmeFile: Regex = #"README\.md"# // MARK: - Checks -// some example lint checks +// MARK: Readme +try Lint.checkFilePaths( + checkInfo: "Readme: Each project should have a README.md file explaining the project.", + regex: readmeFile, + matchingExamples: ["README.md"], + nonMatchingExamples: ["README.markdown", "Readme.md", "ReadMe.md"], + violateIfNoMatchesFound: true +) + +// MARK: ReadmeTypoLicense +try Lint.checkFileContents( + checkInfo: "ReadmeTypoLicense: Misspelled word 'license'.", + regex: #"([\s#]L|l)isence([\s\.,:;])"#, + matchingExamples: [" license:", "## Lisence\n"], + nonMatchingExamples: [" license:", "## License\n"], + includeFilters: [readmeFile], + autoCorrectReplacement: "$1icense$2", + autoCorrectExamples: [ + AutoCorrection(before: " license:", after: " license:"), + AutoCorrection(before: "## Lisence\n", after: "## License\n"), + ] +) // MARK: - Log Summary & Exit Lint.logSummaryAndExit() @@ -282,7 +308,7 @@ When using the `customCheck`, you might want to also include some Swift packages ```swift #!/usr/local/bin/swift-sh -import AnyLint // @Flinesoft ~> 0.1.0 +import AnyLint // @Flinesoft ~> 0.1.1 import Files // @JohnSundell ~> 4.1.1 import ShellOut // @JohnSundell ~> 2.3.0 diff --git a/Sources/AnyLintCLI/ConfigurationTemplates/BlankTemplate.swift b/Sources/AnyLintCLI/ConfigurationTemplates/BlankTemplate.swift index fa429da..ac72f72 100644 --- a/Sources/AnyLintCLI/ConfigurationTemplates/BlankTemplate.swift +++ b/Sources/AnyLintCLI/ConfigurationTemplates/BlankTemplate.swift @@ -10,18 +10,18 @@ enum BlankTemplate: ConfigurationTemplate { let readmeFile: Regex = #"README\.md"# // MARK: - Checks - // MARK: readme + // MARK: Readme try Lint.checkFilePaths( - checkInfo: "readme: Each project should have a README.md file, explaining how to use or contribute to the project.", + checkInfo: "Readme: Each project should have a README.md file, explaining how to use or contribute to the project.", regex: #"^README\.md$"#, matchingExamples: ["README.md"], nonMatchingExamples: ["README.markdown", "Readme.md", "ReadMe.md"], violateIfNoMatchesFound: true ) - // MARK: readme_path + // MARK: ReadmePath try Lint.checkFilePaths( - checkInfo: "readme_path: The README file should be named exactly `README.md`.", + checkInfo: "ReadmePath: The README file should be named exactly `README.md`.", regex: #"^(.*/)?([Rr][Ee][Aa][Dd][Mm][Ee]\.markdown|readme\.md|Readme\.md|ReadMe\.md)$"#, matchingExamples: ["README.markdown", "readme.md", "ReadMe.md"], nonMatchingExamples: ["README.md", "CHANGELOG.md", "CONTRIBUTING.md", "api/help.md"], @@ -33,9 +33,9 @@ enum BlankTemplate: ConfigurationTemplate { ] ) - // MARK: readme_top_level_title + // MARK: ReadmeTopLevelTitle try Lint.checkFileContents( - checkInfo: "readme_top_level_title: The README.md file should only contain a single top level title.", + checkInfo: "ReadmeTopLevelTitle: The README.md file should only contain a single top level title.", regex: #"(^|\n)#[^#](.*\n)*\n#[^#]"#, matchingExamples: [ """ @@ -60,9 +60,9 @@ enum BlankTemplate: ConfigurationTemplate { includeFilters: [readmeFile] ) - // MARK: readme_typo_license + // MARK: ReadmeTypoLicense try Lint.checkFileContents( - checkInfo: "readme_typo_license: Misspelled word 'license'.", + checkInfo: "ReadmeTypoLicense: Misspelled word 'license'.", regex: #"([\s#]L|l)isence([\s\.,:;])"#, matchingExamples: [" lisence:", "## Lisence\n"], nonMatchingExamples: [" license:", "## License\n"], diff --git a/Sources/Utility/Constants.swift b/Sources/Utility/Constants.swift index d8b5041..f1adc14 100644 --- a/Sources/Utility/Constants.swift +++ b/Sources/Utility/Constants.swift @@ -9,7 +9,7 @@ public var log = Logger(outputType: .console) /// Constants to reference across the project. public enum Constants { /// The current tool version string. Conforms to SemVer 2.0. - public static let currentVersion: String = "0.1.0" + public static let currentVersion: String = "0.1.1" /// The name of this tool. public static let toolName: String = "AnyLint" diff --git a/Sources/Utility/Logger.swift b/Sources/Utility/Logger.swift index 87cb3fc..d8a42ab 100644 --- a/Sources/Utility/Logger.swift +++ b/Sources/Utility/Logger.swift @@ -97,7 +97,7 @@ public final class Logger { private func consoleMessage(_ message: String, level: PrintLevel) { switch level { case .success: - print(formattedCurrentTime(), "✅ ", message.green) + print(formattedCurrentTime(), "✅", message.green) case .info: print(formattedCurrentTime(), "ℹ️ ", message.lightBlue) diff --git a/lint.swift b/lint.swift index 000c1ad..b355497 100755 --- a/lint.swift +++ b/lint.swift @@ -453,19 +453,5 @@ try Lint.checkFileContents( includeFilters: [readmeFile] ) -// MARK: ReadmeTypoLicense -try Lint.checkFileContents( - checkInfo: "ReadmeTypoLicense: Misspelled word 'license'.", - regex: #"([\s#]L|l)isence([\s\.,:;])"#, - matchingExamples: [" lisence:", "## Lisence\n"], - nonMatchingExamples: [" license:", "## License\n"], - includeFilters: [readmeFile], - autoCorrectReplacement: "$1icense$2", - autoCorrectExamples: [ - AutoCorrection(before: " lisence:", after: " license:"), - AutoCorrection(before: "## Lisence\n", after: "## License\n"), - ] -) - // MARK: - Log Summary & Exit Lint.logSummaryAndExit()