Skip to content

Instantly share code, notes, and snippets.

@hectorddmx
Forked from guilhermearaujo/README.md
Last active September 14, 2018 19:23
Show Gist options
  • Save hectorddmx/49293f7e5720070c248a771730764747 to your computer and use it in GitHub Desktop.
Save hectorddmx/49293f7e5720070c248a771730764747 to your computer and use it in GitHub Desktop.

Revisions

  1. hectorddmx revised this gist Sep 14, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions oclint.sh
    Original file line number Diff line number Diff line change
    @@ -50,6 +50,7 @@ oclint-json-compilation-database -e Janrain -- -max-priority-1=100000 -max-prior
    -disable-rule=HighNcssMethod \
    -disable-rule=HighNPathComplexity \
    -disable-rule=LongMethod \
    -disable-rule=LongClass \
    -disable-rule=HighCyclomaticComplexity \
    -disable-rule=TooManyMethods \
    -disable-rule=DeepNestedBlock \
  2. hectorddmx revised this gist Sep 14, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion oclint.sh
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@ fi
    rm -f compile_commands.json

    # Build and analyze
    # OCLint Rule Index: http://docs.oclint.org/en/dev/rules/index.html
    # OCLint Rule Index: https://oclint-docs.readthedocs.io/en/v0.13/rules/index.html

    echo "Starting clean and build..."
    xcodebuild -project "${WORKSPACE}" -scheme "${SCHEME}" -configuration Bot \
  3. hectorddmx revised this gist Sep 14, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # OCLint integration with Xcode
    # OCLint (0.13) integration with Xcode

    ## 1. Integration
    * Add a new ***Target*** of kind ***Aggregate***, name it ***OCLint***
  4. hectorddmx revised this gist Sep 14, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -13,4 +13,4 @@

    ## 3. Customization
    * Rules can be ignored by adding the parameter `-disable-rule=<RuleName>` to the `oclint-json-compilation-database` command
    * A comprehensive list of rules can be found at [OCLint documentation](http://docs.oclint.org/en/dev/rules/index.html)
    * A comprehensive list of rules can be found at [OCLint documentation](https://oclint-docs.readthedocs.io/en/v0.13/rules/index.html)
  5. hectorddmx revised this gist Sep 14, 2018. 1 changed file with 38 additions and 23 deletions.
    61 changes: 38 additions & 23 deletions oclint.sh
    Original file line number Diff line number Diff line change
    @@ -1,46 +1,61 @@
    source ~/.bash_profile
    # Original script at
    # https://gist.github.com/guilhermearaujo/a6e4dbb982fea40a0513

    ##source ~/.bash_profile
    export PATH=$PATH:/usr/local/bin/

    if [ -z "${SCHEME+x}" ]
    then
    export SCHEME="${PROJECT_NAME}"
    export SCHEME="${PROJECT_NAME}"
    fi

    # "Workspace" is actually the project
    if [ -z "${WORKSPACE+x}" ]
    then
    export WORKSPACE="${PROJECT_NAME}.xcworkspace"
    export WORKSPACE="${PROJECT_NAME}.xcodeproj"
    fi

    cd "${SOURCE_ROOT}"

    # Check if xctool and oclint are installed
    if ! which -s xctool
    then
    echo 'error: xctool not found, install e.g. with homebrew'
    exit 1
    fi

    # Check if oclint is installed
    if ! which -s oclint-json-compilation-database
    then
    echo 'error: OCLint not installed, install e.g. with homebrew cask'
    exit 2
    echo 'error: OCLint not installed, install e.g. with homebrew cask'
    exit 2
    fi

    # Cleanup before building
    rm -f compile_commands.json
    xctool -workspace "${WORKSPACE}" -scheme "${SCHEME}" clean > /dev/null

    # Build and analyze
    # OCLint Rule Index: http://docs.oclint.org/en/dev/rules/index.html
    xctool -workspace "${WORKSPACE}" -scheme "${SCHEME}" -reporter json-compilation-database:compile_commands.json build
    oclint-json-compilation-database -e Pods -- -max-priority-1=100000 -max-priority-2=100000 -max-priority-3=100000 \
    -disable-rule=InvertedLogic \
    -disable-rule=UnusedMethodParameter \
    -disable-rule=LongLine \
    -disable-rule=LongVariableName \
    -disable-rule=ShortVariableName \
    -disable-rule=UselessParentheses \
    -disable-rule=IvarAssignmentOutsideAccessorsOrInit | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'

    echo "Starting clean and build..."
    xcodebuild -project "${WORKSPACE}" -scheme "${SCHEME}" -configuration Bot \
    clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO > xcodebuild.log
    echo "Finished clean and build project."

    oclint-xcodebuild | xcpretty -r json-compilation-database
    echo "Built json compilation database at ./compile-commands.json"

    # AssignIvarOutsideAccessors is for version 0.13
    # IvarAssignmentOutsideAccessorsOrInit is for 0.10.3 only
    oclint-json-compilation-database -e Janrain -- -max-priority-1=100000 -max-priority-2=100000 -max-priority-3=100000 \
    -disable-rule=InvertedLogic \
    -disable-rule=UnusedMethodParameter \
    -disable-rule=LongLine \
    -disable-rule=LongVariableName \
    -disable-rule=ShortVariableName \
    -disable-rule=UselessParentheses \
    -disable-rule=HighNcssMethod \
    -disable-rule=HighNPathComplexity \
    -disable-rule=LongMethod \
    -disable-rule=HighCyclomaticComplexity \
    -disable-rule=TooManyMethods \
    -disable-rule=DeepNestedBlock \
    -disable-rule=AssignIvarOutsideAccessors \
    -disable-rule=IvarAssignmentOutsideAccessorsOrInit | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'

    # Final cleanup
    rm -f compile_commands.json
    rm -f compile_commands.json
    rm -f xcodebuild.log
  6. @guilhermearaujo guilhermearaujo revised this gist Apr 11, 2015. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions oclint.sh
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,17 @@
    source ~/.bash_profile
    export PATH=$PATH:/usr/local/bin/

    if [ -z ${SCHEME+x} ]
    if [ -z "${SCHEME+x}" ]
    then
    export SCHEME=${PROJECT_NAME}
    export SCHEME="${PROJECT_NAME}"
    fi

    if [ -z ${WORKSPACE+x} ]
    if [ -z "${WORKSPACE+x}" ]
    then
    export WORKSPACE=${PROJECT_NAME}.xcworkspace
    export WORKSPACE="${PROJECT_NAME}.xcworkspace"
    fi

    cd ${SOURCE_ROOT}
    cd "${SOURCE_ROOT}"

    # Check if xctool and oclint are installed
    if ! which -s xctool
    @@ -28,11 +28,11 @@ fi

    # Cleanup before building
    rm -f compile_commands.json
    xctool -workspace ${WORKSPACE} -scheme ${SCHEME} clean > /dev/null
    xctool -workspace "${WORKSPACE}" -scheme "${SCHEME}" clean > /dev/null

    # Build and analyze
    # OCLint Rule Index: http://docs.oclint.org/en/dev/rules/index.html
    xctool -workspace ${WORKSPACE} -scheme ${SCHEME} -reporter json-compilation-database:compile_commands.json build
    xctool -workspace "${WORKSPACE}" -scheme "${SCHEME}" -reporter json-compilation-database:compile_commands.json build
    oclint-json-compilation-database -e Pods -- -max-priority-1=100000 -max-priority-2=100000 -max-priority-3=100000 \
    -disable-rule=InvertedLogic \
    -disable-rule=UnusedMethodParameter \
  7. @guilhermearaujo guilhermearaujo created this gist Mar 12, 2015.
    16 changes: 16 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # OCLint integration with Xcode

    ## 1. Integration
    * Add a new ***Target*** of kind ***Aggregate***, name it ***OCLint***
    * Under *Builde Phases*, add a new ***Run Script Phase***
    * Paste the script

    ## 2. Usage
    * Select target ***OCLint***
    * Build the target (press <kbd>⌘</kbd>+<kbd>B</kbd>)
    * Wait for the script to run
    * Warnings will appear in the *Issue Navigator* (press <kbd>⌘</kbd>+<kbd>4</kbd>)

    ## 3. Customization
    * Rules can be ignored by adding the parameter `-disable-rule=<RuleName>` to the `oclint-json-compilation-database` command
    * A comprehensive list of rules can be found at [OCLint documentation](http://docs.oclint.org/en/dev/rules/index.html)
    46 changes: 46 additions & 0 deletions oclint.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    source ~/.bash_profile
    export PATH=$PATH:/usr/local/bin/

    if [ -z ${SCHEME+x} ]
    then
    export SCHEME=${PROJECT_NAME}
    fi

    if [ -z ${WORKSPACE+x} ]
    then
    export WORKSPACE=${PROJECT_NAME}.xcworkspace
    fi

    cd ${SOURCE_ROOT}

    # Check if xctool and oclint are installed
    if ! which -s xctool
    then
    echo 'error: xctool not found, install e.g. with homebrew'
    exit 1
    fi

    if ! which -s oclint-json-compilation-database
    then
    echo 'error: OCLint not installed, install e.g. with homebrew cask'
    exit 2
    fi

    # Cleanup before building
    rm -f compile_commands.json
    xctool -workspace ${WORKSPACE} -scheme ${SCHEME} clean > /dev/null

    # Build and analyze
    # OCLint Rule Index: http://docs.oclint.org/en/dev/rules/index.html
    xctool -workspace ${WORKSPACE} -scheme ${SCHEME} -reporter json-compilation-database:compile_commands.json build
    oclint-json-compilation-database -e Pods -- -max-priority-1=100000 -max-priority-2=100000 -max-priority-3=100000 \
    -disable-rule=InvertedLogic \
    -disable-rule=UnusedMethodParameter \
    -disable-rule=LongLine \
    -disable-rule=LongVariableName \
    -disable-rule=ShortVariableName \
    -disable-rule=UselessParentheses \
    -disable-rule=IvarAssignmentOutsideAccessorsOrInit | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'

    # Final cleanup
    rm -f compile_commands.json