Tailor is a 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 supports Swift 2 out of the box and helps enforce style guidelines outlined in the The Swift Programming Language, GitHub, Ray Wenderlich, and Coursera style guides.

tailor-site
tailor-wiki

I have integrated Tailor with Jenkins in a job “iOS Tailor Testing – App Example”
tailor –format=json . | tailorf >> tailor_report.html

tailorf is a python formatter created to convert json tailor output in html report.

Structure Project tailorf
tailorf-project

 

 

 

 

 

Source code of tailorf:

tailor.html ->

<!DOCTYPE html>
<html>
<head>
    <title>Tailor Report</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
<body>

<div class="container">

<h2>TAILOR REPORT</h2>


<h3>

Summary
</h3>


<table class="table table-condensed">

<td>
            {% for key, value in data.summary.iteritems() %}

<tr>{{ key }}: {{ value }}</tr>

            
            {% endfor %}
        </td>

    </table>





    {% for file in data.files %}

<h4>

{{ basename_function(file.path, prefix) }}
</h4>


<table class="table table-condensed table-bordered">

<tr>

<td><strong>Severity</strong></td>


<td><strong>Rule</strong></td>


<td><strong>Location - line/column</strong></td>


<td><strong>Error message</strong></td>

        </tr>

        {% for error in file.violations %}

<tr>

<td>
                <mark>{{ error.severity }}</mark>
            </td>


<td>{{ error.rule }}</td>


<td>{{ error.location.line }}/{{ error.location.column }}</td>


<td><em>{{ error.message }}</em></td>

        </tr>

        {% endfor %}
    </table>





    {% endfor %}
</div>

</body>
</html>

 

__init__.py ->

import json
import os
import sys

from jinja2 import Environment, PackageLoader


def __basename_function(path, prefix):
    return os.path.relpath(path, prefix)


def format(file=sys.stdin):
    env = Environment(loader=PackageLoader('tailorf', 'templates'))
    env.globals['basename_function'] = __basename_function
    data = json.load(file)
    paths = [file["path"] for file in data["files"]]
    prefix = os.path.commonprefix(paths)
    template = env.get_template('tailor.html')
    print template.render(data=data, prefix=prefix)

 

requirements.txt ->
jinja2
setuptools

 

setup.cfg ->
[metadata]
description-file = README.md

 

README.md ->
tailorf
================

 

setup.py ->

from setuptools import setup

setup(
    name='tailorf',
    packages=['tailorf'],
    version='0.1.1',
    description='Format tailor json output to HTML',
    author='Giuseppe Cilia',
    author_email='pinschertesting@gmail.com',
    url='https://gitlab_url/tailor-formatter',
    download_url='https://gitlab_url/tailor-formatter/repository/archive.targ.gz?ref=0.1.1',
    keywords=['formatter', 'tailor', 'html'],
    classifiers=[],
    install_requires=['jinja2'],
    package_data={'tailorf': ['templates/*.html']},
    entry_points={
        'console_scripts': [
            'tailorf = tailorf:format',
        ]
    }
)

 

How to install tailorf?
sudo pip install tailorf

tailorf-report

 

 

 

 

 

 

share me!:))Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someonePrint this page