sleekbyte / tailor Goto Github PK
View Code? Open in Web Editor NEWCross-platform static analyzer and linter for Swift.
Home Page: https://sleekbyte.github.io/tailor
License: MIT License
Cross-platform static analyzer and linter for Swift.
Home Page: https://sleekbyte.github.io/tailor
License: MIT License
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'pmd'
Do not use parentheses around:
for
while
repeat while
if
switch
guard
throw
catch
array items
dictionary items
initializer
The following constructs should be named using the lowerCamelCase format:
func someMethod() {
// method definition goes here
}
var someVariable = someValue
Allow user to set a maximum line count restriction in
By default, the user will be allowed to create files and methods with infinite number of lines.
No spaces:
Potentially also add an option to use the "note" message style. These will not show up in the editor window, but will be displayed in the Build Log under "All Messages".
Test cases:
// TODO: Use
== once #33 "Buffer output in printer class and remove duplicate error messages" is complete
The ANTLR API does not seem to throw any exceptions but rather just print to STDERR, this output could be captured and tested for emptiness to detect errors and abort walking the partial tree or invoking the FileListener.
Alternatively, investigate use of ANTLRErrorStrategy
along with Parser.notifyErrorListeners(java.lang.String)
and/or reportError(Parser recognizer, RecognitionException e)
to report any kind of RecognitionException
.
e.g. constants.py
based on Constant String File in Python
Sort the set of messages output by Printer
with line as primary sort and column as secondary sort. Dependent on #33.
Steps to automate:
antlr4
on modified grammar*.token
filestailor/swift
Ensure TODO comments are defined as follows in single line comments //
:
// TODO: <insert mandatory todo comment>
// TODO(dev-name): <insert mandatory todo comment>
Note: Nested single line comments will be analyzed and flagged.
Xcode will point to a specific character if both line and column are specified, but this doesn't always make sense for some rules (e.g. file too long). Modify logic in Location
and Printer
classes to support column parameter being optional.
// TODO: #33: Use printer method where column is unspecified
This will also help in isolating functional tests to specific features, tests should be modified to use these flags once implemented.
For example (based on Pylint):
--enable=semicolon,uppercamelcase,lowercamelcase,kprefix
(whitelist)
AND
--disable=semicolon,redundantparens,closureparens
(blacklist)
The following constructs should be named using the UpperCamelCase format:
class SomeClass {
// class definition goes here
}
enum SomeEnumeration {
// enumeration definition goes here
}
enum CompassPoint {
case North
case South
case East
case West
}
struct SomeStructure {
// structure definition goes here
}
protocol SomeProtocol {
// protocol definition goes here
}
script
main
listeners
and utils
output
Avoid single letter variable/constant names except in for loops
Preferred:
let rowHeight = contentHeight + ((hasHeader == true) ? 50 : 20)
Not Preferred:
let rowHeight = contentHeight + (hasHeader == true ? 50 : 20)
Preferred
let MaxHeight = 666
Not Preferred
let kMaxHeight = 666
The project wiki should:
These docstrings will be verified by pylint
and pep257
in pre-commit hooks, however short functions/classes and tests may be exempt
One of:
Multiple positional command line arguments should be supported, each of which is a Swift source file to be analyzed. This includes shell glob expansion.
New language features to support:
Preferred:
someFunctionThatTakesAClosure {
// trailing closure's body goes here
}
Not Preferred:
someFunctionThatTakesAClosure() {
// trailing closure's body goes here
}
Example:
let digitNames = [
0: "Zero", 1: "One", 2: "Two", 3: "Three", 4: "Four",
5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine"
]
let numbers = [16, 58, 510]
let strings = numbers.map {
(var number) -> String in
var output = ""
while number > 0 {
output = digitNames[number % 10]! + output
number /= 10
}
return output
}
// strings is inferred to be of type [String]
// its value is ["OneSix", "FiveEight", "FiveOneZero"]
By default, the max line length and max variable/constant name lengths will be infinite.
Restrict name lengths of:
The printer counts column numbers from 0 instead of 1. This leads to inaccurate error/warning messages.
Example
If the error message is on line 1 and column 4, then the printer will claim that the error is on line 1 and column 3.
Preferred:
import Foundation
import Cocoa
Not Preferred:
import Foundation; import Cocoa
The functional test harness will diff the generated output from STDOUT
against the expected functional test output *Tests.out
.
Users should be given a choice to use lowerCamelCase or UpperCamelCase to name global constants.
Users are suggested to use lowerCamelCase names for local constants.
Related issues: #96, #100, #132, #135
Open brace should be on same line as statement
class SomeClass: SomeSuperClass {
}
class Demo {
}
func someMethod() {
}
if someCondition {
}
else if someCondition {
}
else {
}
switch someCase {
default:
break
}
for var x = 0; x < 10; x+=1 {
}
for ; ; {
}
for var x ; ; {
}
for ; x ; {
}
for ; ; x {
}
for var x; x ; {
}
for var x; ; x {
}
for ; x ; x {
}
while someCondition {
}
repeat {
} while someCondition
for someElement in someCollection {
}
init(length:Double, breadth:Double) {
self.length = length
self.breadth = breadth
}
struct DemoStruct : SomeParentStruct {
}
struct DemoStruct {
}
Preferred
prefix operator += {}
Not Preferred
prefix operator +-+ {}
prefix operator ** {}
{
brace (except for compound assignment operators +=
)Preferred
func helloWorld {
// do something
}
Not Preferred
func helloWorld{
// do something
}
class hello {
var message: String
}
//
in commentsPreferred
// this is a comment
Not Preferred
//this is a comment
Preferred
/* This is a
multiline comment */
Not Preferred
/*This is a
multiline comment*/
Preferred
var x: Int = 2
Not Preferred
var x : Int
var y: String
Preferred
var x = [ 'key1': 1, 'key2': 2 ]
var y: [ Int: String ]
Not Preferred
var x = [ 'key1' : 1, 'key2': 3]
var y: [ Int : String ]
Preferred
switch character {
case "a": doSomething(a);
default: alert();
}
Not Preferred
switch character {
case "a" : doSomething(a);
default: alert();
}
Preferred
class ClassName: BaseClass {
}
struct StructName: BaseStruct {
}
protocol ProtocolName: AnotherProtocol {
}
extension TypeName: ProtocolName {
}
Not Preferred
class ClassName : BaseClass {
}
struct StructName: BaseStruct {
}
protocol ProtocolName:AnotherProtocol {
}
extension TypeName : ProtocolName {
}
Preferred
var x = condition ? a : b
Not Preferred
var x = condition ? a: b
var x = condition ? a : b
Preferred
var y = (key: 1, value: 2)
Not Preferred
var y = (key:1, value : 2)
Preferred
func someFunction<T: SomeClass, U: SomeProtocol>(someT: T, someU: U) {
}
Not Preferred
func someFunction<T : SomeClass, U:SomeProtocol>(someT: T, someU: U) {
}
Preferred:
let swift = "compiled language"
Not Preferred:
let swift = "compiled language";
Create a printer module (printer.py
) with basic print functions for different severity levels.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.