-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Remove init requirement & syntax sugar from Withable #50
Conversation
Here is an overview of what got changed by this pull request: Issues
======
- Added 50
See the complete overview on Codacy |
excludeFilters: [testFiles], | ||
autoCorrectReplacement: #"{ $1 in"#, | ||
autoCorrectExamples: [ | ||
["before": "run { (a) in", "after": "run { a in"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Don't use parantheses around non-typed parameters in a closure.
autoCorrectExamples: [ | ||
["before": "run { (a) in", "after": "run { a in"], | ||
["before": "run { (a, b) in", "after": "run { a, b in"], | ||
["before": "run { (a, b, c) in", "after": "run { a, b, c in"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Multi-line collection literals should have trailing commas.
excludeFilters: [testFiles], | ||
autoCorrectReplacement: "$callPart1!.$callPart2!.$callPart3", | ||
autoCorrectExamples: [ | ||
["before": "let x = (viewModel?.profile?.imagePath)!\n", "after": "let x = viewModel!.profile!.imagePath\n"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Don't use ? first to force unwrap later ? directly unwrap within the parantheses.
excludeFilters: [testFiles], | ||
autoCorrectReplacement: "$callPart1!.$callPart2!.$callPart3!.$callPart4", | ||
autoCorrectExamples: [ | ||
["before": "let x = (viewModel?.user?.profile?.imagePath)!\n", "after": "let x = viewModel!.user!.profile!.imagePath\n"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Multi-line collection literals should have trailing commas.
// MARK: EmptyTodo | ||
try Lint.checkFileContents( | ||
checkInfo: "EmptyTodo: `// TODO:` comments should not be empty.", | ||
regex: #"// TODO: ?(\[[\d\-_a-z]+\])? *\n"#, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try Lint.checkFileContents( | ||
checkInfo: "SingleLineGuard: Use a single line guard for simple checks.", | ||
regex: #"guard\s*([^\{]{2,80})\s+else\s*\{\s*\n\s*(return[^\n]{0,40}|continue|fatalError\([^\n;]+\))\s*\}"#, | ||
matchingExamples: ["guard x else {\n return\n}", "guard x else {\n return 2 * x.squared(x: {15})\n}", #"guard x else {\#n fatalError("some message: \(x)")\#n}"#], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Line should be 160 characters or less: currently 173 characters
"callPart3": #"[^\s\?\.]+"#, | ||
"separator3": #"\?\."#, | ||
"callPart4": #"[^\s\?\.]+"#, | ||
"closingBraceUnwrap": #"\)!"# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Multi-line collection literals should have trailing commas.
["before": "init(\n x: Int,\n y: Int\n) {\n \n}", "after": "init(\n x: Int,\n y: Int\n) {}"], | ||
["before": "func foo2bar() { }", "after": "func foo2bar() {}"], | ||
["before": "func foo2bar(x: Int, y: Int) { }", "after": "func foo2bar(x: Int, y: Int) {}"], | ||
["before": "func foo2bar()\n{\n \n}", "after": "func foo2bar() {}"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try Lint.checkFileContents( | ||
checkInfo: "EmptyTodo: `// TODO:` comments should not be empty.", | ||
regex: #"// TODO: ?(\[[\d\-_a-z]+\])? *\n"#, | ||
matchingExamples: ["// TODO:\n", "// TODO: [2020-03-19]\n", "// TODO: [cg_2020-03-19] \n"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
dataExporterHelper.exportData( | ||
""" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Multi-line collection literals should have trailing commas.
@@ -0,0 +1,547 @@ | |||
#!/usr/local/bin/swift-sh | |||
import AnyLint // @Flinesoft ~> 0.8.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Header comments should be consistent with project patterns.
checkInfo: "SingleLineGuard: Use a single line guard for simple checks.", | ||
regex: #"guard\s*([^\{]{2,80})\s+else\s*\{\s*\n\s*(return[^\n]{0,40}|continue|fatalError\([^\n;]+\))\s*\}"#, | ||
matchingExamples: ["guard x else {\n return\n}", "guard x else {\n return 2 * x.squared(x: {15})\n}", #"guard x else {\#n fatalError("some message: \(x)")\#n}"#], | ||
nonMatchingExamples: ["guard x else { return }", "guard x else { return 2 * x.squared(x: {15}) }", #"guard x else { fatalError("some message: \(x)") }"#], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Line should be 160 characters or less: currently 162 characters
|
||
// MARK: IfAsGuard | ||
try Lint.checkFileContents( | ||
checkInfo: "IfAsGuard: Don't use an if statement to just return – use guard for such cases instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Always start a multiline guard via guard
then a line break and all expressions indented.
excludeFilters: [testFiles], | ||
autoCorrectReplacement: "$callPart1!.$callPart2", | ||
autoCorrectExamples: [ | ||
["before": "call(x: (viewModel?.username)!)", "after": "call(x: viewModel!.username)"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Multi-line collection literals should have trailing commas.
} | ||
""", | ||
""" | ||
guard let collection = viewModel.myCollection(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Always start a multiline guard via guard
then a line break and all expressions indented.
try Lint.checkFileContents( | ||
checkInfo: "NavigationControllerVariableNaming: Always name your navigation controller variables with the suffix `NavCtrl` or just `navCtrl`.", | ||
regex: #"(var|let) +(nc|navigationcontroller|navc|ncontroller|navcontroller)[ :][^\n=]*=\i"#, | ||
matchingExamples: ["let nc =", "var navigationController =", "let navc =", "let ncontroller =", "var nc: MyNavigationController =", "let navController: MyNavigationController<T> = "], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Always name your view controller variables with the suffix ViewCtrl
.
try Lint.checkFileContents( | ||
checkInfo: "ClosureParamsParantheses: Don't use parantheses around non-typed parameters in a closure.", | ||
regex: #"\{\s*\(((?!self)[^):]+)\)\s*in"#, | ||
matchingExamples: ["run { (a) in", "run { (a, b) in", "run { (a, b, c) in"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Don't use parantheses around non-typed parameters in a closure.
regex: #"guard\s*([^\n]*,\n)+([^\n]*\S *)else\s*\{"#, | ||
matchingExamples: [ | ||
""" | ||
guard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Always close a multiline guard via else {
on a new line indented like the opening guard
.
excludeFilters: [testFiles], | ||
autoCorrectReplacement: "$callPart1!.$callPart2", | ||
autoCorrectExamples: [ | ||
["before": "call(x: (viewModel?.username)!)", "after": "call(x: viewModel!.username)"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Don't use ? first to force unwrap later ? directly unwrap within the parantheses.
"callPart3": #"[^\s\?\.]+"#, | ||
"closingBraceUnwrap": #"\)!"# | ||
], | ||
matchingExamples: ["call(x: (viewModel?.profile?.username)!)"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Don't use ? first to force unwrap later ? directly unwrap within the parantheses.
"closingBraceUnwrap": #"\)!"# | ||
], | ||
matchingExamples: ["call(x: (viewModel?.username)!)"], | ||
nonMatchingExamples: ["call(x: (viewModel?.profile?.username)!)", "call(x: viewModel!.username)"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Don't use ? first to force unwrap later ? directly unwrap within the parantheses.
["before": "init()\n{\n \n}", "after": "init() {}"], | ||
["before": "init(\n x: Int,\n y: Int\n) {\n \n}", "after": "init(\n x: Int,\n y: Int\n) {}"], | ||
["before": "func foo2bar() { }", "after": "func foo2bar() {}"], | ||
["before": "func foo2bar(x: Int, y: Int) { }", "after": "func foo2bar(x: Int, y: Int) {}"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkInfo: "EmptyTodo: `// TODO:` comments should not be empty.", | ||
regex: #"// TODO: ?(\[[\d\-_a-z]+\])? *\n"#, | ||
matchingExamples: ["// TODO:\n", "// TODO: [2020-03-19]\n", "// TODO: [cg_2020-03-19] \n"], | ||
nonMatchingExamples: ["// TODO: refactor", "// TODO: not yet implemented", "// TODO: [cg_2020-03-19] not yet implemented"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// MARK: SingleLineGuard | ||
try Lint.checkFileContents( | ||
checkInfo: "SingleLineGuard: Use a single line guard for simple checks.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Always start a multiline guard via guard
then a line break and all expressions indented.
], | ||
[ | ||
"before": "param: callFunction(errorMessage != nil ? errorMessage! : L10n.Global.Info.success),\n", | ||
"after": "param: callFunction(errorMessage ?? L10n.Global.Info.success),\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codacy found an issue: Multi-line collection literals should have trailing commas.
@knothed What do you think of this? Since you implemented this in the first place, do you agree with my changes? |
Fixes #49.
Proposed Changes
init()
requirement fromWithable
.init
syntax sugar method that allowedFoo { $0.bar = 5}
in favor ofFoo().with { $0.bar = 5}
.Foo(bar: 5).with { $0.otherProperty = true }
without requiringinit()
onFoo
type.