Cross-platform static analyzer and linter for Swift.

Overview

Tailor

Build Status Code Coverage Code Climate

WikiInstallationUsageFeaturesDevelopersLicense

Tailor is a cross-platform static analysis and lint tool for source code written in Apple's Swift programming language. It analyzes your code to ensure consistent styling and help avoid bugs.

Tailor. Cross-platform static analyzer and linter for Swift.

Tailor supports Swift 3.0.1 out of the box and helps enforce style guidelines outlined in the The Swift Programming Language, GitHub, Ray Wenderlich, and Coursera style guides. It supports cross-platform usage and can be run on Mac OS X via your shell or integrated with Xcode, as well as on Linux and Windows.

Tailor parses Swift source code using the primary Java target of ANTLR:

ANTLR is a powerful parser generator [ . . . ] widely used in academia and industry to build all sorts of languages, tools, and frameworks.

About the ANTLR Parser Generator

Getting Started

Installation

Requires Java (JRE or JDK) Version 8 or above: Java SE Downloads

Homebrew, Linuxbrew

brew install tailor

Mac OS X (10.10+), Linux

curl -fsSL https://tailor.sh/install.sh | sh

Windows (10+)

iex (new-object net.webclient).downloadstring('https://tailor.sh/install.ps1')

Manually

You may also download Tailor via GitHub Releases, extract the archive, and symlink the tailor/bin/tailor shell script to a location in your $PATH.

Continuous Integration

If your continuous integration server supports Homebrew installation, you may use the following snippet:

before_install:
  - brew update
  - brew install tailor

In other cases, use this snippet:

Replace ${TAILOR_RELEASE_ARCHIVE} with the URL of the release you would like to install, e.g. https://github.com/sleekbyte/tailor/releases/download/v0.1.0/tailor.tar.

before_script:
  - wget ${TAILOR_RELEASE_ARCHIVE} -O /tmp/tailor.tar
  - tar -xvf /tmp/tailor.tar
  - export PATH=$PATH:$PWD/tailor/bin/

Usage

Run Tailor with a list of files and directories to analyze, or via Xcode.

$ tailor [options] [--] [[file|directory] ...]

Help for Tailor is accessible via the [-h|--help] option.

$ tailor -h
Usage: tailor [options] [--] [[file|directory] ...]

Perform static analysis on Swift source files.

Invoking Tailor with at least one file or directory will analyze all Swift files at those paths. If
no paths are provided, Tailor will analyze all Swift files found in '$SRCROOT' (if defined), which
is set by Xcode when run in a Build Phase. Tailor may be set up as an Xcode Build Phase
automatically with the --xcode option.

Options:
 -c,--config=<path/to/.tailor.yml>             specify configuration file
    --debug                                    print ANTLR error messages when parsing error occurs
    --except=<rule1,rule2,...>                 run all rules except the specified ones
 -f,--format=<xcode|json|cc|html>              select an output format
 -h,--help                                     display help
    --invert-color                             invert colorized console output
 -l,--max-line-length=<0-999>                  maximum Line length (in characters)
    --list-files                               display Swift source files to be analyzed
    --max-class-length=<0-999>                 maximum Class length (in lines)
    --max-closure-length=<0-999>               maximum Closure length (in lines)
    --max-file-length=<0-999>                  maximum File length (in lines)
    --max-function-length=<0-999>              maximum Function length (in lines)
    --max-name-length=<0-999>                  maximum Identifier name length (in characters)
    --max-severity=<error|warning (default)>   maximum severity
    --max-struct-length=<0-999>                maximum Struct length (in lines)
    --min-name-length=<1-999>                  minimum Identifier name length (in characters)
    --no-color                                 disable colorized console output
    --only=<rule1,rule2,...>                   run only the specified rules
    --purge=<1-999>                            reduce memory usage by clearing DFA cache after
                                               specified number of files are parsed
    --show-rules                               show description for each rule
 -v,--version                                  display version
    --xcode=<path/to/project.xcodeproj>        add Tailor Build Phase Run Script to Xcode Project

Features

Enabling and Disabling Rules

Rule identifiers and "preferred/not preferred" code samples may be found on the Rules page.

Rules may be individually disabled (blacklist) or enabled (whitelist) via the --except and --only command-line flags.

Except

tailor --except=brace-style,trailing-whitespace main.swift

Only

tailor --only=redundant-parentheses,terminating-semicolon main.swift

Cross-Platform

Tailor may be used on Mac OS X via your shell or integrated with Xcode, as well as on Linux and Windows.

Linux

Tailor on Ubuntu

Windows

Tailor on Windows

Automatic Xcode Integration

Tailor can be integrated with Xcode projects using the --xcode option.

tailor --xcode /path/to/demo.xcodeproj/

This adds the following Build Phase Run Script to your project's default target. Run Script

Tailor's output will be displayed inline within the Xcode Editor Area and as a list in the Log Navigator. Xcode messages

Configure Xcode to Analyze Code Natively (⇧⌘B)

  1. Add a new configuration, say Analyze, to the project

screen shot 2016-11-30 at 12 29 34 am

  1. Modify the active scheme's Analyze phase to use the new build configuration created above

screen shot 2016-11-30 at 12 37 08 am

  1. Tweak the build phase run script to run Tailor only when analyzing the project (⇧⌘B)
if [ "${CONFIGURATION}" = "Analyze" ]; then
    if hash tailor 2>/dev/null; then
        tailor
    else
        echo "warning: Please install Tailor from https://tailor.sh"
    fi
fi

Colorized Output

Tailor uses the following color schemes to format CLI output:

  • Dark theme (enabled by default) Dark theme

  • Light theme (enabled via --invert-color option) Light theme

  • No color theme (enabled via --no-color option) No color

Warnings, Errors, and Failing the Build

--max-severity can be used to control the maximum severity of violation messages. It can be set to error or warning (by default, it is set to warning). Setting it to error allows you to distinguish between lower and higher priority messages. It also fails the build in Xcode, if any errors are reported (similar to how a compiler error fails the build in Xcode). With max-severity set to warning, all violation messages are warnings and the Xcode build will never fail.

This setting also affects Tailor's exit code on the command-line, a failing build will exit 1 whereas having warnings only will exit 0, allowing Tailor to be easily integrated into pre-commit hooks.

Disable Violations within Source Code

Violations on a specific line may be disabled with a trailing single-line comment.

import Foundation; // tailor:disable

Additionally, violations in a given block of code can be disabled by enclosing the block within tailor:off and tailor:on comments.

// tailor:off
import Foundation;
import UIKit;
import CoreData;
// tailor:on

class Demo() {
  // Define public members here
}

Note

  • // tailor:off and // tailor:on comments must be paired

Configuration

The behavior of Tailor can be customized via the .tailor.yml configuration file. It enables you to

  • include/exclude certain files and directories from analysis
  • enable and disable specific analysis rules
  • specify output format
  • specify CLI output color scheme

You can tell Tailor which configuration file to use by specifying its file path via the --config CLI option. By default, Tailor will look for the configuration file in the directory where you will run Tailor from.

The file follows the YAML 1.1 format.

Including/Excluding files

Tailor checks all files found by a recursive search starting from the directories given as command line arguments. However, it only analyzes Swift files that end in .swift. If you would like Tailor to analyze specific files and directories, you will have to add entries for them under include. Files and directories can also be ignored through exclude.

Here is an example that might be used for an iOS project:

include:
    - Source            # Inspect all Swift files under "Source/"
exclude:
    - '**Tests.swift'   # Ignore Swift files that end in "Tests"
    - Source/Carthage   # Ignore Swift files under "Source/Carthage/"
    - Source/Pods       # Ignore Swift files under "Source/Pods/"

Notes

  • Files and directories are specified relative to where tailor is run from
  • Paths to directories or Swift files provided explicitly via CLI will cause the include/exclude rules specified in .tailor.yml to be ignored
  • Exclude is given higher precedence than Include
  • Tailor recognizes the Java Glob syntax

Enabling/Disabling rules

Tailor allows you to individually disable (blacklist) or enable (whitelist) rules via the except and only labels.

Here is an example showcasing how to enable certain rules:

# Tailor will solely check for violations to the following rules
only:
    - upper-camel-case
    - trailing-closure
    - forced-type-cast
    - redundant-parentheses

Here is an example showcasing how to disable certain rules:

# Tailor will check for violations to all rules except for the following ones
except:
    - parenthesis-whitespace
    - lower-camel-case

Notes

  • only is given precedence over except
  • Rules that are explicitly included/excluded via CLI will cause the only/except rules specified in .tailor.yml to be ignored

Specifying output format

Tailor allows you to specify the output format (xcode/json) via the format label.

Here is an example showcasing how to specify the output format:

# The output format will now be in JSON
format: json

Note

  • The output format explicitly specified via CLI will cause the output format defined in .tailor.yml to be ignored

Specifying CLI output color scheme

Tailor allows you to specify the CLI output color schemes via the color label. To disable colored output, set color to disable. To invert the color scheme, set color to invert.

Here is an example showcasing how to specify the CLI output color scheme:

# The CLI output will not be colored
color: disable

Note

  • The CLI output color scheme explicitly specified via CLI will cause the output color scheme defined in .tailor.yml to be ignored

Formatters

Tailor's output format may be customized via the -f/--format option. The Xcode formatter is selected by default.

Xcode Formatter (default)

The default xcode formatter outputs violation messages according to the format expected by Xcode to be displayed inline within the Xcode Editor Area and as a list in the Log Navigator. This format is also as human-friendly as possible on the console.

$ tailor main.swift

********** /main.swift **********
/main.swift:1:    warning: [multiple-imports] Imports should be on separate lines
/main.swift:1:18: warning: [terminating-semicolon] Statements should not terminate with a semicolon
/main.swift:3:05: warning: [constant-naming] Global Constant should be either lowerCamelCase or UpperCamelCase
/main.swift:5:07: warning: [redundant-parentheses] Conditional clause should not be enclosed within parentheses
/main.swift:7:    warning: [terminating-newline] File should terminate with exactly one newline character ('\n')

Analyzed 1 file, skipped 0 files, and detected 5 violations (0 errors, 5 warnings).

JSON Formatter

The json formatter outputs an array of violation messages for each file, and a summary object indicating the parsing results and the violation counts.

$ tailor -f json main.swift
{
  "files": [
    {
      "path": "/main.swift",
      "violations": [
        {
          "severity": "warning",
          "rule": "constant-naming",
          "location": {
            "line": 1,
            "column": 5
          },
          "message": "Global Constant should be either lowerCamelCase or UpperCamelCase"
        }
      ],
      "parsed": true
    }
  ],
  "summary": {
    "violations": 1,
    "warnings": 1,
    "analyzed": 1,
    "errors": 0,
    "skipped": 0
  }
}

HTML Formatter

The html formatter outputs a complete HTML document that should be written to a file.

tailor -f html main.swift > tailor.html

HTML format

Developers

Please review the guidelines for contributing to this repository.

Development Environment

External Tools and Libraries

Development & Runtime

Tool License
ANTLR 4.5 The BSD License
Apache Commons CLI Apache License, Version 2.0
Jansi Apache License, Version 2.0
Xcodeproj MIT
SnakeYAML Apache License, Version 2.0
Gson Apache License, Version 2.0
Mustache.java Apache License, Version 2.0

Development Only

Tool License
Gradle Apache License, Version 2.0
Travis CI Free for Open Source Projects
Mockito MIT
JUnit Eclipse Public License 1.0
Java Hamcrest The BSD 3-Clause License
FindBugs GNU Lesser General Public License
Checkstyle GNU Lesser General Public License
PMD BSD-style
JaCoCo Eclipse Public License v1.0
Coveralls Free for Open Source
Bundler MIT
Codacy Free for Open Source
System Rules Common Public License 1.0
Ronn MIT

License

Tailor is released under the MIT license. See LICENSE.md for details.

Comments
  • Configure Xcode to Analyze Code Natively way does not work for workspaces

    Configure Xcode to Analyze Code Natively way does not work for workspaces

    Tailor Version: v0.11.1

    Swift Version: 3.0

    Platform (Mac/Linux/Windows/CI): Mac OS Siera

    Installation Method: Curl

    Steps to Reproduce Issue

    1. Use Xcode as described https://github.com/sleekbyte/tailor "Configure Xcode to Analyze Code Natively" try to analyze workspace (create Analyze scheme and run Analyze from Xcode menu) for example

    Expected Behavior

    Analyze workspace

    Actual Behavior

    Cannot find pods

    opened by evgzor 7
  • Add swift4 keyPath support

    Add swift4 keyPath support

    \ can now be used to specify keyPaths, so I added one usage in Macros.swift and patched the grammar file

    See : https://github.com/apple/swift-evolution/blob/master/proposals/0161-key-paths.md and https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/zzSummaryOfTheGrammar.html

    enhancement 
    opened by kenji21 6
  • Support Swift 3

    Support Swift 3

    What is the gameplan / status regarding supporting the recently released Swift 3 update? This release appears to introduce syntax changes that would affect the underlying parser. Is this under consideration?

    opened by esheri3 6
  • Crasher in BraceStyleListener

    Crasher in BraceStyleListener

    Tailor will crash when parsing this valid Swift:

    var foo: Bool {
        willSet { self.bar(newValue) }
    }
    

    With a java trace:

    $ tailor tailor-crasher.swift 
    Exception in thread "main" java.lang.NullPointerException
    at com.sleekbyte.tailor.listeners.BraceStyleListener.verifyWillSetClauseBraceStyle(BraceStyleListener.java:312)
    at com.sleekbyte.tailor.listeners.BraceStyleListener.enterWillSetClause(BraceStyleListener.java:134)
    at com.sleekbyte.tailor.antlr.SwiftParser$WillSetClauseContext.enterRule(SwiftParser.java:5768)
    at org.antlr.v4.runtime.tree.ParseTreeWalker.enterRule(ParseTreeWalker.java:66)
    at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:49)
    at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
    at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
    at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
    at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
    at org.antlr.v4.runtime.tree.ParseTreeWalker.walk(ParseTreeWalker.java:52)
    at com.sleekbyte.tailor.Tailor.analyzeFiles(Tailor.java:285)
    at com.sleekbyte.tailor.Tailor.main(Tailor.java:344)
    
    duplicate 
    opened by alexkent 5
  • Multiple conditionals should be valid

    Multiple conditionals should be valid

    Tailor Version: v0.1.0

    Swift Version: 2.2

    Platform (Mac/Linux/Windows/CI): Mac

    Installation Method: curl script

    Steps to Reproduce Issue

    guard
       let strongSelf = self,
       let data = jsonData,
       let convos = data["items"] as? [[String: AnyObject]] else {
    
          return
       }
    

    Expected Behavior

    Should be valid

    Actual Behavior

    Generates a violation

    wontfix 
    opened by thefredelement 4
  • [parenthesis-whitespace] rule flags parens preceded by braces

    [parenthesis-whitespace] rule flags parens preceded by braces

    Tailor Version: v0.9.0 Swift Version: 2.2 Platform (Mac/Linux/Windows/CI): Mac Installation Method: Homebrew

    The Parenthesis-Whitespace rule should not exist. It makes no sense, especially in closures.

    It turns functions that look like this:

    MyClass.executeClosure { (param) -> retVal in
    
    }
    

    to the following:

    MyClass.executeClosure {(param) -> retVal in
    
    }
    

    Looks really ugly.

    I'm disabling the rule, but I hope you consider removing it.

    bug 
    opened by ArtSabintsev 4
  • Except rules are ignored in .tailor.yml

    Except rules are ignored in .tailor.yml

    Regardless of what I put in the except: block of the .tailor.yml file, none of these declarations are respected by tailor.

    For example, with the following except block:

    except:
        - trailing-whitespace
    

    The trailing-whitespace rule is still being triggered.

    question 
    opened by lyptt 4
  • Extremely poor performance

    Extremely poor performance

    I attempted to use Tailor to analyse this open-source app. After 10 minutes of maxing out my 4 cores JVM OOMed. I assume this is a limitation based on ANTLR-generated parser being used but I was wondering if you can think of some ways of improving performance by at least an order of magnitude? ;) I'm afraid I don't have much experience to provide meaningful input but one thing that limited memory consumption (to some 1.2GB) when I played around with the grammar was something like this:

    private static ParseTree parseTreeFrom(String content) {
      CharStream input = new UnbufferedCharStream(new StringReader(content));
      SwiftLexer lex = new SwiftLexer(input);
      lex.setTokenFactory(new CommonTokenFactory(true));
      TokenStream tokens = new UnbufferedTokenStream<CommonToken>(lex);
      SwiftParser parser = new SwiftParser(tokens);
      parser.setTrimParseTree(true);
      return parser.topLevel();
    }
    

    That did not curb insane CPU usage, though. I'm wondering if you have any insights.

    enhancement 
    opened by marcinwyszynski 4
  • Allow exceptions to lowerCamelCase rule in the case of all-caps acronyms

    Allow exceptions to lowerCamelCase rule in the case of all-caps acronyms

    For example, Apple's APIs typically expose a URL method argument as URL:

    init?(URL url: NSURL, resolvingAgainstBaseURL resolve: Bool)
    convenience init(URL URL: NSURL)
    init(URL URL: NSURL, entersReaderIfAvailable entersReaderIfAvailable: Bool)
    init?(URL url: NSURL, statusCode statusCode: Int, HTTPVersion HTTPVersion: String?, headerFields headerFields: [String: String]?)
    

    However, these methods would all be flagged by Tailor.

    What do you think about a rule which allows an exception to the lowerCamelCase rule in the case that the name begins with a range of 2 or more all-caps characters (to avoid letting UpperCamelCase pass), followed by camelCase after that?

    enhancement 
    opened by chadmoone 4
  • #303: Support multiple output formats

    #303: Support multiple output formats

    Resolves #303.

    • [x] Add infrastructure to specify output format on command-line
    • [x] Support both Xcode and JSON formats
    • [x] Add tests
    • [x] Add Gson license to README
    • [x] Bundle Gson license with distribution
    • [x] Update --help output in README
    • [x] Document output formats in README
    feature 
    opened by alykhank 4
  • Need exception-rule for handling of equatable protocol

    Need exception-rule for handling of equatable protocol

    For a class to conform to the Equatable protocol, it must define a function of the of the following form:

    func ==(lhs: Class, rhs: Class) -> Bool
    

    Unfortunately, Tailor throws a warning here: [lower-camel-case] Function names should be lowerCamelCase

    I know I can add some inline code to silence this warning, but I think Tailor should treat this as an exception to the lower-camel-case rule.

    duplicate 
    opened by ArtSabintsev 4
  •  java.lang.OutOfMemoryError

    java.lang.OutOfMemoryError

    Tailor Version: v0.12.0

    Swift Version: 5.5

    When i run the tailor, i got this error

    Running Tailor...Exception in thread "main" java.lang.OutOfMemoryError at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:564) at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:591) at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:689) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:159) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:173) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233) at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:765) at com.sleekbyte.tailor.Tailor.analyzeFiles(Tailor.java:304) at com.sleekbyte.tailor.Tailor.main(Tailor.java:376) Caused by: java.lang.OutOfMemoryError: Java heap space at org.antlr.v4.runtime.atn.ParserATNSimulator.getEpsilonTarget(ParserATNSimulator.java:1779) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1541) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583) at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1513) at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1583)

    opened by ebubekirsezer 0
  • Migrate LGTM.com installation from OAuth to GitHub App

    Migrate LGTM.com installation from OAuth to GitHub App

    Hi There,

    This project is still using an old implementation of LGTM's automated code review, which has now been disabled. To continue using automated code review, and receive checks on your Pull Requests, please install the GitHub App on this repository.

    Thanks, The LGTM Team

    opened by LGTM-badger 0
  • Windows: Only checking for the registry entry might not be a valid way to check if Java is installed.

    Windows: Only checking for the registry entry might not be a valid way to check if Java is installed.

    Tailor Version: v0.12.0 Platform (Mac/Linux/Windows/CI): Windows Installation Method: Powershell Script

    I have installed java version "11.0.4" 2019-07-16 LTS on my Windows 10 machine and correctly set the JAVA_HOME environment variable.

    The HKLM:\SOFTWARE\JavaSoft\Java Runtime Environment does not exist on my machine, thus trying to install resolved in an error. There's a HKLM:\SOFTWARE\JavaSoft\JDK\11 though. Commenting the verify-java() function in the .ps1 script installs tailor successfully.

    Maybe checking for which java or something similar is better than checking for the registry entry.

    opened by moritzgloeckl 0
  • How to analyse all files in once ?

    How to analyse all files in once ?

    Tailor Version: v0.1.0

    Swift Version: 4.2

    Platform (Mac/Linux/Windows/CI): Mac

    Installation Method: Homebrew

    Steps to Reproduce Issue

    Expected Behavior

    Actual Behavior

    opened by ShiwaniNtz 0
  • How to configure tailor in project which has .workspace and .xcodeproject. it gives error when i try with .xcodeproject, it works fine without pods projects.

    How to configure tailor in project which has .workspace and .xcodeproject. it gives error when i try with .xcodeproject, it works fine without pods projects.

    Tailor Version: v0.1.0

    Swift Version: 4.2

    Platform (Mac/Linux/Windows/CI): Mac

    Installation Method: Homebrew

    Steps to Reproduce Issue

    1. I have installed Homebrew successfully.
    2. I have tried it with some other .xcodeproject which has no pods.
    3. When i try to run the command tailor --xcode with the project which has pods it gives error Integration Error: Invalid .xcodeproj file

    Expected Behavior

    Actual Behavior

    opened by ShiwaniNtz 0
  • Issue while adding a new rule

    Issue while adding a new rule

    Tailor Version: v0.11.1 Platform (Mac/Linux/Windows/CI): windows Hi ,

    I added a new rule inside com.sleekbyte.tailor.listeners as abc.java and wrote unit test file inside com.sleekbyte.tailor.functional and abc.swift inside \src\test\swift\com\sleekbyte\tailor\functional. Also i wrote metadata and registered abc rule inside Rule.java and Message.java but while building i am getting following error:

    java.lang.IllegalArgumentException: 4 > 2 at java.util.Arrays.copyOfRange(Arrays.java:3480) at java.util.Arrays.copyOfRange(Arrays.java:3441) at com.sleekbyte.tailor.functional.RuleTest.testRule(RuleTest.java:69) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.mockito.internal.runners.SilentJUnitRunner.run(SilentJUnitRunner.java:39) at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:35) at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:104) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:106) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:748)

    Any help would be highly appreciated! Thanks!

    opened by vickyrocky 2
Releases(v0.12.0)
  • v0.12.0(Mar 27, 2017)

  • v0.11.1(Oct 12, 2016)

  • v0.11.0(Sep 23, 2016)

  • v0.10.1(Aug 24, 2016)

  • v0.10.0(May 6, 2016)

    This release adds an HTML output format, offers configuration functionality for tuning memory usage, and improves the reliability of the [brace-style] rule.

    Changes

    • #389: Add HTML report option via --format html (CLI) / format: html (.tailor.yml)
    • #414: Add --purge <1-999> (CLI) / purge: <1-999> (.tailor.yml) option for tuning memory usage
    • #405: Ensure that [brace-style] checks whitespace between { and the previous token
    Source code(tar.gz)
    Source code(zip)
    tailor-0.10.0.tar(2.58 MB)
    tailor-0.10.0.zip(2.26 MB)
  • v0.9.1(May 2, 2016)

    This release ensures that closure signatures contain a single whitespace preceding any (, removes [trailing-closure] checks inside condition clauses, and improves parsing of attributes, string interpolation, getters / setters, and external parameter names.

    Changes

    • #385: Fix several grammar issues to improve parsing of attributes, string interpolation
    • #393: Allow declaration modifiers on getters and setters (e.g. nonmutating set)
    • #397: Ensure that (most) keywords can be used as external parameter names without escaping
    • #400: Verify that ( in closure signatures are preceded by one whitespace
    • #401: Suppress [trailing-closure] checks within condition clauses
    Source code(tar.gz)
    Source code(zip)
    tailor-0.9.1.tar(2.47 MB)
    tailor-0.9.1.zip(2.16 MB)
  • v0.9.0(Apr 23, 2016)

  • v0.8.1(Apr 21, 2016)

  • v0.8.0(Apr 19, 2016)

    This release allows regions to be excluded from analysis via // tailor:off and // tailor:on directives, fixes parsing of the #selector macro, adds more documentation to the Code Climate format, and reduces [todo-syntax] warnings.

    Changes

    • #324: Allow // tailor:off and // tailor:on comments to exclude regions from analysis
    • #354: Ensure #selector macro is parsed correctly (Swift 2.2)
    • #367: Add sample code for rules in Code Climate format
    • #355: Restrict [todo-syntax] checks to comments containing TODO as an independent word
    Source code(tar.gz)
    Source code(zip)
    tailor-0.8.0.tar(2.47 MB)
    tailor-0.8.0.zip(2.16 MB)
  • v0.7.0(Mar 23, 2016)

    This release adds a new format for integration with the Code Climate platform, adds new configuration options to the .tailor.yml config file, and fixes several grammar issues.

    Changes

    • #346: Add Code Climate format
    • #340: Allow customization of format and color options via .tailor.yml
    • #278: Fix parsing of quoted strings within string interpolation
    • #343: Add safe to valid Swift identifiers, allow named parameter subscripts, and let in import statements
    • #349: Fix exception on invalid number of CLI arguments
    Source code(tar.gz)
    Source code(zip)
    tailor-0.7.0.tar(2.45 MB)
    tailor-0.7.0.zip(2.14 MB)
  • v0.6.0(Feb 12, 2016)

  • v0.5.1(Feb 5, 2016)

    This release allows inclusion/exclusion of rules from the .tailor.yml config file via only and exclude to match the CLI. The JSON formatter now encapsulates all output in a single root document for easier machine parsing. Single-line comments at the end of a file that is missing a terminating newline are now parsed correctly.

    Changes

    • #285: Allow users to include/exclude rules via config file
    • #317: Group JSON output into single root element
    • #315: Allow single-line comments to terminate with EOF
    Source code(tar.gz)
    Source code(zip)
    tailor-0.5.1.tar(2.43 MB)
    tailor-0.5.1.zip(2.13 MB)
  • v0.5.0(Jan 31, 2016)

    This release adds the ability to view violation messages in multiple formats via -f/--format, namely the existing Xcode format and now JSON. A man page for the command-line interface has been added, try man tailor after installation. Two new rules, [redundant-optional-binding] and [trailing-closure] have been added. [comma-whitespace] now checks all possible constructs. [lower-camel-case] will allow identifiers that begin with 2 or more capital letters (i.e. acronyms).

    Changes

    • #303: Support multiple output formats via -f/--format, add JSON format
    • #142: Create man page for CLI, accessible via man tailor
    • #289: Add [redundant-optional-binding] rule to flag redundant let/var usages
    • #307: Suggest trailing closure syntax for final closure arguments with [trailing-closure] rule
    • #240: Add [comma-whitespace] checks for all remaining constructs
    • #305: Allow exceptions to [lower-camel-case] if tokens begin with 2+ capital letters (acronyms)
    • #300: Fix ClassCastException in ColonWhitespaceListener
    Source code(tar.gz)
    Source code(zip)
    tailor-0.5.0.tar(2.43 MB)
    tailor-0.5.0.zip(2.13 MB)
  • v0.4.0(Jan 8, 2016)

    This release enforces the absence of spaces in several constructs with the [angle-bracket-whitespace] and [parentheses-whitespace] rules, and removes the [lower-camel-case] violation for operator definition functions while ensuring that they are surrounded by whitespace for clarity. The positioning of commas for several constructs is now checked by the [comma-whitespace] rule, and several grammar issues have been resolved.

    Changes

    • #87: Enforce absence of spaces between parentheses & content, angle brackets & content, and function name & parameter list
    • #271: Remove [lower-camel-case] violation for operator definition functions
    • #267: Ensure operator definitions are surrounded by whitespace
    • #276: Fix grammar issues: removing new keyword, allow variadic parameter types, parse where in for in loops correctly
    • #240: Verify that commas are left-associated for several constructs
    • #280: Do not flag absence of whitespace between generic parameter clauses and parameter clauses
    Source code(tar.gz)
    Source code(zip)
    tailor-0.4.0.tar(2.17 MB)
    tailor-0.4.0.zip(1.91 MB)
  • v0.3.0(Nov 23, 2015)

    This release splits the [whitespace] rule up into separate rules: [arrow-whitespace], [colon-whitespace], [comma-whitespace], and [operator-whitespace], adds a [min-name-length] rule, and checks for redundant empty parentheses following a method call with a trailing closure. It also ensures that an Xcode warning is displayed when the Tailor Run Script is executed in an environment that does not have Tailor installed and includes a fix for issues with analyzing willSet and didSet constructs.

    Changes

    • #239: Split [whitespace] rule into multiple rules
    • #90: Allow minimum limits to be specified for identifier names
    • #69: Ensure parentheses are omitted if function call uses single trailing closure argument
    • #244: Display an Xcode warning if Tailor is not installed
    • #249: Fix brace style analysis of willSet and didSet constructs
    Source code(tar.gz)
    Source code(zip)
    tailor-0.3.0.tar(2.17 MB)
    tailor-0.3.0.zip(1.91 MB)
  • v0.2.2(Nov 8, 2015)

    This release updates the grammar to support Swift 2.1, ensures that generic parameters also conform to the UpperCamelCase naming convention, adds further checks for comma spacing to the [whitespace] rule, and fixes #226 to ensure that Tailor's exit status always matches the number of errors displayed.

    Changes

    • #236: Update grammar to support Swift 2.1
    • #91: Enforce comma spacing in inheritance/protocol lists and generics
    • #107: Ensure generic parameters are UpperCamelCase, e.g. class Dictionary<Key, Value>
    • #226: Correctly match exit status to number of displayed errors
    Source code(tar.gz)
    Source code(zip)
    tailor.tar(2.15 MB)
    tailor.zip(1.90 MB)
  • v0.2.1(Nov 1, 2015)

    This release ensures that Tailor automatic Xcode configuration works irrespective of the directory where Tailor is installed, and adds a [todo-syntax] rule that validates the TODO style recognized by Xcode.

    Changes

    • #68: Enforce TODO comment syntax, e.g. either // TODO: comment or // TODO(dev-name): comment
    • #217: Make Xcode integration path-agnostic
    Source code(tar.gz)
    Source code(zip)
    tailor.tar(2.21 MB)
    tailor.zip(1.95 MB)
  • v0.2.0(Oct 31, 2015)

    This release adds a Configuration feature to Tailor, allowing custom inclusion and exclusion glob patterns for finding Swift files via a tailor.yml config file. It also includes several grammar/parsing fixes, and an adjustment to the [comment-whitespace] rule to allow for documentation-style comments.

    Changes

    • #203: Enable configuration of included and excluded files via .tailor.yml
    • #211: Allow documentation comment strings /// and /**
    • #202: Fix parsing of backslashes in strings, e.g. "\u{f26e}"
    • #209: Allow punctuation in attributes, e.g. @objc(beforeEachWithMetadata:)), and ensure that variables can be named optional
    Source code(tar.gz)
    Source code(zip)
    tailor.tar(2.20 MB)
    tailor.zip(1.94 MB)
A static source code analysis tool to improve quality and reduce defects for C, C++ and Objective-C

OCLint - https://oclint.org OCLint is a static code analysis tool for improving quality and reducing defects by inspecting C, C++ and Objective-C code

The OCLint Static Code Analysis Tool 3.6k Dec 29, 2022
Measure Swift code metrics and get reports in Xcode, Jenkins and other CI platforms.

Taylor ⚠️ Taylor is DEPRECATED. Use SwiftLint instead. A tool aimed to increase Swift code quality, by checking for conformance to code metrics. Taylo

YOPESO 301 Dec 24, 2022
A tool for Swift code modification intermediating between code generation and formatting.

swift-mod A tool for Swift code modification intermediating between code generation and formatting. Overview swift-mod is a tool for Swift code modifi

Ryo Aoyama 95 Nov 3, 2022
SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations.

SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations. Objective Build a stan

Andres Canal 542 Sep 17, 2022
A command-line tool and Xcode Extension for formatting Swift code

Table of Contents What? Why? How? Command-line tool Xcode source editor extension Xcode build phase Via Applescript VSCode plugin Sublime Text plugin

Nick Lockwood 6.3k Jan 8, 2023
A tool to enforce Swift style and conventions.

SwiftLint A tool to enforce Swift style and conventions, loosely based on the now archived GitHub Swift Style Guide. SwiftLint enforces the style guid

Realm 16.9k Jan 9, 2023
Type-safe observable values and collections in Swift

GlueKit ⚠️ WARNING ⚠️ This project is in a prerelease state. There is active work going on that will result in API changes that can/will break code wh

null 361 Oct 12, 2022
Trackable is a simple analytics integration helper library. It’s especially designed for easy and comfortable integration with existing projects.

Trackable Trackable is a simple analytics integration helper library. It’s especially designed for easy and comfortable integration with existing proj

Vojta Stavik 145 Apr 14, 2022
Makes it easier to support older versions of iOS by fixing things and adding missing methods

PSTModernizer PSTModernizer carefully applies patches to UIKit and related Apple frameworks to fix known radars with the least impact. The current set

PSPDFKit Labs 217 Aug 9, 2022
Find common xib and storyboard-related problems without running your app or writing unit tests.

IBAnalyzer Find common xib and storyboard-related problems without running your app or writing unit tests. Usage Pass a path to your project to ibanal

Arek Holko 955 Oct 15, 2022
Skredvarsel app - an iOS, iPadOS, and macOS application that provides daily avalanche warnings from the Norwegian Avalanche Warning Service API

Skredvarsel (Avalanche warning) app is an iOS, iPadOS, and macOS application that provides daily avalanche warnings from the Norwegian Avalanche Warning Service API

Jonas Follesø 8 Dec 15, 2022
Simple iOS app blackbox assessment tool. Powered by frida.re and vuejs.

Discontinued Project This project has been discontinued. Please use the new Grapefruit #74 frida@14 compatibility issues frida@14 introduces lots of b

Chaitin Tech 1.6k Dec 16, 2022
Exclude files and folders from Alfred’s search results

Ignore in Alfred Alfred Workflow Exclude files and folders from Alfred’s search results ⤓ Download Workflow About The macOS metadata search API only a

Alfred 10 Dec 13, 2022
Lint anything by combining the power of Swift & regular expressions.

Installation • Getting Started • Configuration • Xcode Build Script • Donation • Issues • Regex Cheat Sheet • License AnyLint Lint any project in any

Flinesoft 116 Sep 24, 2022
An Xcode formatter plug-in to format your swift code.

Swimat Swimat is an Xcode plug-in to format your Swift code. Preview Installation There are three way to install. Install via homebrew-cask # Homebrew

Jintin 1.6k Jan 7, 2023
💊 Syntactic sugar for Swift do-try-catch

Fallback Syntactic sugar for Swift do-try-catch. At a Glance value = try fallback( try get("A"), try get("B"), try get("C"), try get("D") ) is

Suyeol Jeon 43 May 25, 2020
A Swift micro-framework to easily deal with weak references to self inside closures

WeakableSelf Context Closures are one of Swift must-have features, and Swift developers are aware of how tricky they can be when they capture the refe

Vincent Pradeilles 72 Sep 1, 2022
Swift-lint-plugin - A SwiftPM plugin that adds a linting command

SwiftLintPlugin This is a SwiftPM plugin that adds a lint command. SwiftPM plugi

null 9 Nov 23, 2022
Aplicação Basica em Swift desenvolvida com o intuito de aplicar os conceitos estudados

Via Cep iOS Sobre - Interface do Usuario - Tecnologias - Requisitos - Autor Projeto ?? FINALIZADO ?? Sobre A Aplicação consiste em fazer buscas usando

Igor Damasceno de Sousa 1 Jun 3, 2022