Code Monkey home page Code Monkey logo

capp_lint's Introduction

NAME
    capp_lint.py -- check formatting of Objective-J files

SYNOPSIS
    capp_lint.py [options] [file ... | -]

DESCRIPTION
    capp_lint.py is a formatting checker for Objective-J. It performs a number of checks that catch
    common formatting mistakes, as defined in the Cappuccino coding style guidelines
    (http://cappuccino.org/contribute/coding-style.php).

    capp_lint.py operates on a list of files and/or directory. You may pass one or more paths (relative to the
    current working directory) as arguments to capp_lint.py, or if the first path is "-", the
    list of paths is taken from stdin, in which case everything after the "-" is ignored.

    If a path is a directory, the directory is recursively scanned for *.j files to check. Symbolic links
    are not followed.

    The following options are available:

    -b/--basedir=BASEDIR
        The base directory relative to which filenames will be resolved. If not passed,
        it defaults to the current working directory.

    -d/--var-declarations=[none|single|strict]
        Determines the policy in flagging consecutive var declarations. The choices are:
            none - No checking is done.
            single - If two var blocks appear consecutively and one of them is
                     a single variable, the second var block will be flagged.
            strict - Any consecutive var declarations will be flagged.

        Given the following code:

            var foo = "bar",
                bar = "foo";

            var bow = "foobar",
                wow = "woof";

        The "none" policy will obviously not flag this. The "single" policy will not flag
        this because both blocks contain more than one declaration. The "strict" policy
        will flag this. Given the following code:

            var foo = "bar",
                bar = "foo";

            var bow = "foobar";

        The "single" policy will flag this because the second block is a single declaration.

    -f/--format=[text|html]
        Determines the format of the error output. See the OUTPUT section below for more information
        on the different formats.

    -q/--quiet
        Normally capp_lint.py will print a list of the errors it finds. If this option is passed,
        the error list is suppressed. This option is mutually exclusive with the -v option.

    -v/--verbose
        Displays each line as it is processed by capp_lint.py with a line number,
        along with some information about syntactic information it finds.

    --version
        Displays the current version and exits.

    -h/--help
        Shows a synopsis of the usage and options and exits.

    The following formatting errors are flagged by capp_lint.py:

    - Lines which contain one or more tabs.
    - Lines which contain non-ASCII characters not within quoted strings.
    - Lines which contain malformed UTF-8.
    - Missing space between control statements and their opening parentheses.
    - Trailing whitespace.
    - Binary operators without surrounding space.
    - Assignment operators without surrounding space.
    - Comparison operators without surrounding space.
    - Useless unary + operators.
    - Extra or missing space in a method declaration.
    - Superflous function names.
    - Unterminated variable blocks.
    - Consecutive var statements.
    - Incorrect indentation in a var block.
    - Missing statement separators in a var block.
    - Inadvertent global variables in a var block.
    - Unbalanced [, { or ( in a variable block.
    - Opening braces on the same line as a statement.
    - Code following a var block that is not outdented from the var block.

EXIT STATUS
    capp_lint.py exits with a return status of one if it finds any errors. If no errors are found,
    it exits with a return status of zero.

OUTPUT
    For each error that capp_lint.py finds, if the -q/--quiet option was not passed, capp_lint.py
    will output an error like the following if the error format is text:

    AppKit/CPObjectController.j:482: assignment operator without surrounding spaces.
    +    for (var i=0, count=[_observationProxies count]; i<count; i++)
                   ^        ^

    The filename (relative to the working directory), line number, and type of error are displayed
    first, followed by the offending line of source code. When possible and necessary (as in this example),
    the location of the errors is indicated below the source line. If only a single file was checked,
    the filename is suppressed.

    If the error format is html, the output is similar, but instead of using markers to indicate where
    the errors occurred, the character at that position is highlighted. In addition, clicking on the
    error open TextMate to the file and line number of the error.

WHITESPACE
    Cappuccino coding standards stipulate that there should be no trailing whitespace, and that tabs
    should consist of 4 spaces, not tab characters. capp_lint will report trailing whitespace and hard tabs.
    You should fix those errors before paying attention to any other errors, as the presence of hard tabs
    may cause some false positives.

TEXTMATE INTEGRATION
    To integrate capp_lint.py into TextMate, double-click capp_lint.tmbundle to install it into TextMate.
    Before the bundle can be used, you must make capp_lint.py available to TextMate. The bundle will
    look in the following places:

    - capp_lint.tmbundle/Support/bin/capp_lint.py
    - The path specified by the TextMate shell variable TM_CAPP_LINT (set in TextMate Preferences).
      The path should include the filename of the executable file.
    - capp_lint.py or capp_lint in your PATH.

    The bundle has four commands, accessed by default by pressing Control-L:

    - Check current document, show the results in HTML with clickable errors.
    - Check current document, show the results in a tooltip.
    - Recursively check the selected documents and/or directories in the project drawer.
    - Recursively check the entire project.

    VAR_DECLARATIONS POLICY
    You can set a value for --var-declarations by creating and enabling the TextMate
    shell variable TM_CAPP_LINT_VAR_DECLARATIONS in TextMate Preferences. The value should
    be one of [none|single|strict]. If not set, the default policy is single.


KNOWN BUGS
    capp_lint.py will currently flag false positives for the following cases I know of:

    var foo =
    [
        "bar"
    ]

    - missing statement separator

    var x, y, z;

    - unterminated var block. This is not actually a bug -- multiple variables are not supposed
      to be declared on a single line. The error condition is not properly described.

AUTHORS
    Aparajita Fishman, Victory-Heart Productions
    [email protected]

capp_lint's People

Contributors

aljungberg avatar aparajita avatar klaaspieter avatar

Watchers

Jacob Swartwood avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.