You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/07/19 00:44:04 UTC

[GitHub] [incubator-weex] wrmswindmill opened a new pull request #2731: Add Lint in TravisCI and Update iOS TravisCI

wrmswindmill opened a new pull request #2731: Add Lint in TravisCI and Update iOS TravisCI
URL: https://github.com/apache/incubator-weex/pull/2731
 
 
   # Brief Description of the PR
   Add Static Check in Travis CI
   
   
   ## Lint Tool Lists:
   1. [oclint](http://oclint.org) : for c,c++,objective-c
   2. [android lint]():for android project
   
   ## Check FileType 
   ```javascript
   const getFileType = file => {
     if (file.match(/.+\.(m|h|mm|cpp|cc)/)) {
       return type_c;
     } else if (file.match(/.+\.java/)) {
       return type_android;
     } else if (file.match(/.+\.js/)) {
       return type_js;
     }else{
       return type_unknown;
     }
   }
   ```
   
   ## OCLint in ,travis.yml
   ```yaml
   - env: STATIC_CODE_ANALYSIS=true CHECK_C=true
        language: objective-c
        osx_image: xcode7.2
   
   before_install:
     - |
       # install oclint
       if [[ ("${STATIC_CODE_ANALYSIS}" = "true") && ("${CHECK_C}" = "true") ]]; then
         brew cask uninstall oclint
         brew tap oclint/formulae
         brew install oclint
       fi
   
   install:
      elif [[ ("$TEST_SUITE" = "jsfm") || ("$TEST_SUITE" = "danger") ||  ("${CHECK_C}" = "true") ]]; then
           npm install
       ;;
   
   script:
   if [[ ("${STATIC_CODE_ANALYSIS}" = "true") && ("${CHECK_C}" = "true") ]]; then
         hasCFile=$(npm run danger -- run --dangerfile ./dangerfile-static-check.js)
         echo "The value of hasCFile is ${hasCFile}"
         if [[ "$hasCFile" =~ "hasCFile" ]]; then
           echo "hasCFile"
           cd ios/sdk && xcodebuild | xcpretty -r json-compilation-database -o compile_commands.json
           oclint-json-compilation-database oclint_args -- \
             -disable-rule=ShortVariableName \
             -disable-rule=LongLine \
             -disable-rule=LongMethod \
             -disable-rule=HighNcssMethod \
             -disable-rule=LongVariableName \
             -disable-rule=HighCyclomaticComplexity \
             -disable-rule=HighNPathComplexity \
             -disable-rule=UnusedLocalVariable \
             -disable-rule=DoubleNegative \
             -disable-rule=MultipleUnaryOperator \
             -disable-rule=DeepNestedBlock \
             -max-priority-1=15000 \
             -max-priority-2=15000 \
             -max-priority-3=15000
         fi
       fi 
   ```
   
   ## Update iOS
   ```yaml
   install:
     elif [[ ("$TEST_SUITE" = "ios") ]]; then
       npm install
       cd weex-playground/ios && pod install --repo-update
       cd ../../
     fi
   script:
     # build WeexSDK and run WeexSDKTests
     xcodebuild -project ios/sdk/WeexSDK.xcodeproj test -scheme WeexSDKTests CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -destination "platform=iOS Simulator,name=iPhone 6"
     # build WeexDemo and run WeexDemo test
     xcodebuild -workspace weex-playground/ios/WeexDemo.xcworkspace test -scheme WeexDemo CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -destination "platform=iOS Simulator,name=iPhone 6" | grep -A 5 error
   ```
   
   ## Todo
   [] Discuss OCLint Rules
   [] Discuss Android Rules
   [] Increase ESLint And Discuss Rules
   
   ## Links
   1. OCLint Rules:http://docs.oclint.org/en/stable/rules/index.html

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services