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 ``` ## Android Lint in .travis.yml ```yaml - env: STATIC_CODE_ANALYSIS=true CHECK_ANDROID=true language: android dist: trusty jdk: oraclejdk8 android: components: - android-26 - extra-android-m2repository install: if [[ ("$TEST_SUITE" = "android") || ("${CHECK_ANDROID}" = "true") ]]; then curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash nvm install 7.6 npm install echo y | sdkmanager "cmake;3.6.4111459" if find "${HOME}/android-ndk-r18b" -mindepth 1 | read; then echo "NDK cache hit" else echo "NDK cache missed" rmdir "${HOME}/android-ndk-r18b" fi if [[ ! -d "${HOME}/android-ndk-r18b" ]]; then wget https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip unzip android-ndk-r18b-linux-x86_64.zip -d $HOME fi export ANDROID_NDK_HOME=$HOME/android-ndk-r18b export PATH=$PATH:$ANDROID_NDK_HOME echo "ndk.dir=$ANDROID_NDK_HOME" > android/local.properties script: if [[ ("${STATIC_CODE_ANALYSIS}" = "true") && ("${CHECK_ANDROID}" = "true") ]]; then hasAndroidFile=$(npm run danger -- run --dangerfile ./dangerfile-static-check.js) echo "The value of hasAndroidFile is ${hasAndroidFile}" if [[ "$hasAndroidFile" =~ "hasAndroidFile" ]]; then echo "hasAndroidFile" cd android ./gradlew clean assembleDebug test lint 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 - [x] Discuss Android 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: [email protected] With regards, Apache Git Services
