A tool aimed to increase Swift code quality, by checking for conformance to code metrics.
Taylor uses SourceKitten to a more accurate AST representation and generates the final report in either Xcode, JSON, PMD or plain text formats.
You need to have Homebrew installed.
brew update
brew install taylor
Rebuild dependencies by running carthage bootstrap --platform Mac
(Carthage required)
Clone the project and run make install
(latest version of Xcode required).
Download the latest release and run:
Taylor.app/Contents/Resources/install
To get warnings displayed in the IDE add a new Run Script Phase with:
if which taylor >/dev/null; then
taylor -p ${PROJECT_DIR} -r xcode
else
echo "Taylor not installed"
fi
To use Taylor from command line run it as follows:
taylor [option1 [option1_argument]] [option2 option2_argument] […]
taylor |
Description |
---|---|
-h /--help |
Print help. |
-v /--version |
Print Taylor version. |
-p /--path path |
Path to the folder to be analysed (current folder by default). |
-e /--exclude file |
Path to either directory or file to be excluded from analysis. |
-ef /--excludeFile file |
Path to exclude file in .yml format. |
-f /--file file |
File to be included in analysis (may be from an external source). |
-t /--type type |
Type of files to be analysed. |
-vl /--verbosityLevel level |
Verbosity level for output messages (info, warning and error). |
-r /--reporter type:name |
Type of final report (json, xcode, pmd or plain text) and filename. |
-rc /--ruleCustomization rule=value |
Customize rules by giving custom values. See help for more details. |
taylor
alone with no arguments analyses .swift
files inside current folder.
If you want to exclude some files or folders from checking create a new .yml
file and call Taylor with
-ef /path/to/file
argument.
Default filename is excludes.yml
and its default location is the folder
specified by --path
flag.
The following excluding name formats can be specified:
- "/path/to/file"
- "file"
- "Folder"
- "Folder/*"
- ".*Tests.*"
These are the code quality rules currently existing:
Number of lines in a class must not exceed given limit. Default limit = 400 lines
.
Example: taylor -rc ExcessiveClassLength=100
.
Number of lines in a method must not exceed given limit. Default limit = 20 lines
.
Example: taylor -rc ExcessiveMethodLength=10
.
Number of methods in a class must not exceed given limit. Default limit = 10 methods
.
Example: taylor -rc TooManyMethods=7
.
Cyclomatic Complexity number of a method must not exceed maximal admitted value. Default = 5
.
Example: taylor -rc CyclomaticComplexity=10
.
Block Depth of a method must not exceed maximal admitted value. Default = 3
.
Example: taylor -rc NestedBlockDepth=7
.
N-Path Complexity of a method must not exceed maximal admitted value. Default = 100
.
Example: taylor -rc NPathComplexity=50
.
Number of parameters given to a method must not exceed maximal admitted value. Default = 3
.
Example: taylor -rc ExcessiveParameterList=5
.
Thanks to JP Simard for developing SourceKitten.
MIT Licensed.