From e24ea442b8e1c4bf4efb42df1df79f47ab30eb61 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 25 Sep 2023 16:16:18 +0800 Subject: [PATCH 01/24] [3.4.0-map-sdk] add rules --- codequality/baseline.xml | 0 codequality/detekt.gradle | 37 ++ codequality/detekt.yml | 799 ++++++++++++++++++++++++++++++++++++++ codequality/pmd.gradle | 2 +- 4 files changed, 837 insertions(+), 1 deletion(-) create mode 100644 codequality/baseline.xml create mode 100644 codequality/detekt.yml diff --git a/codequality/baseline.xml b/codequality/baseline.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/codequality/detekt.gradle b/codequality/detekt.gradle index e69de29bb2..39fbca4670 100644 --- a/codequality/detekt.gradle +++ b/codequality/detekt.gradle @@ -0,0 +1,37 @@ +apply plugin: 'io.gitlab.arturbosch.detekt' + +def pmdConfigPath = rootProject.file("codequality").path + +detekt{ + //将配置文件应用于detekt的默认配置文件之上 + buildUponDefaultConfig = true + source = files( + "src/main/kotlin", + "src/jinlvvan/kotlin", + "src/driverm1/kotlin" + ) + //规则集 + config.setFrom("${pmdConfigPath}/detekt.yml") + //指定基准文件。在detekt的后续运行中,所有发现都存储在此文件中 + baseline = files("${pmdConfigPath}/baseline.xml") + //指定格式化报告中文件路径的基本路径 + basePath = projectDir.path + + // Android: Don't create tasks for the specified build types (e.g. "release") +// ignoredBuildTypes = ["release"] + // Android: Don't create tasks for the specified build flavor (e.g. "production") +// ignoredFlavors = ["production"] + // Android: Don't create tasks for the specified build variants (e.g. "productionRelease") +// ignoredVariants = ["productionRelease"] +} + +tasks.detekt.jvmTarget = "1.8" + +tasks.named("detekt").configure { + reports { + // Enable/Disable HTML report (default: true) + def destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") + html.required.set(true) + html.outputLocation.set(destination) + } +} \ No newline at end of file diff --git a/codequality/detekt.yml b/codequality/detekt.yml new file mode 100644 index 0000000000..79fe7453d9 --- /dev/null +++ b/codequality/detekt.yml @@ -0,0 +1,799 @@ +build: + excludeCorrectable: false + +config: + validation: true + warningsAsErrors: false + checkExhaustiveness: false + # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' + excludes: '' + +processors: + active: true + exclude: + - 'DetektProgressListener' + # - 'KtFileCountProcessor' + # - 'PackageCountProcessor' + # - 'ClassCountProcessor' + # - 'FunctionCountProcessor' + # - 'PropertyCountProcessor' + # - 'ProjectComplexityProcessor' + # - 'ProjectCognitiveComplexityProcessor' + # - 'ProjectLLOCProcessor' + # - 'ProjectCLOCProcessor' + # - 'ProjectLOCProcessor' + # - 'ProjectSLOCProcessor' + # - 'LicenseHeaderLoaderExtension' + +console-reports: + active: true + exclude: + - 'ProjectStatisticsReport' + - 'ComplexityReport' + - 'NotificationReport' + - 'FindingsReport' + - 'FileBasedFindingsReport' + # - 'LiteFindingsReport' + +output-reports: + active: true + exclude: + # - 'TxtOutputReport' + # - 'XmlOutputReport' + - 'HtmlOutputReport' + # - 'MdOutputReport' + # - 'SarifOutputReport' + +comments: + active: false + AbsentOrWrongFileLicense: #报告每个没有所需许可证标头的Kotlin源文件 + active: false + licenseTemplateFile: 'license.template' + licenseTemplateIsRegex: false + CommentOverPrivateFunction: #报告private函数的注释和文档 + active: false + CommentOverPrivateProperty: #报告私有属性的注释和文档 + active: false + DeprecatedBlockTag: #报告注释中使用@deprecated块标记,可以使用@ReplaceWith annotations + active: false + EndOfSentenceFormat: #验证KDoc注释的第一句话的结尾 + active: false + endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' + KDocReferencesNonPublicProperty: #报告任何引用类的非公共属性的KDoc注释 + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + OutdatedDocumentation: #报告任何具有与声明签名不匹配的KDoc的类、函数或构造函数 + active: false + matchTypeParameters: true + matchDeclarationsOrder: true + allowParamOnConstructorProperties: false + UndocumentedPublicClass: #报告没有所需文档的公共类、对象和接口 + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + searchInNestedClass: true + searchInInnerClass: true + searchInInnerObject: true + searchInInnerInterface: true + searchInProtectedClass: false + UndocumentedPublicFunction: #报告任何没有所需文档的公共方法 + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + searchProtectedFunction: false + UndocumentedPublicProperty: #报告任何没有所需文档的公共字段 + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + searchProtectedProperty: false + +complexity: + active: true + CognitiveComplexMethod: #报告复杂方法 + active: false + allowedComplexity: 15 + ComplexCondition: #报告复杂条件 + active: false + allowedConditions: 4 + ComplexInterface: #包含太多函数和/或属性的复杂接口表明该接口一次处理太多事情。接口应该遵循单一责任原则,以鼓励该接口的实现不要同时处理太多事情 + active: false + allowedDefinitions: 10 + includeStaticDeclarations: false + includePrivateDeclarations: false + ignoreOverloaded: false + + #该规则使用McCabe的循环复杂性(MCC)度量来测量函数源代码中线性独立路径的数量{https://www.ndepend.com/docs/code-metrics#CC} + CyclomaticComplexMethod: #复杂的方法很难理解和阅读。复杂方法的副作用可能并不明显。更喜欢把复杂的方法分解成更小的方法,这样更容易理解。较小的方法也可以命名得更清晰,从而提高代码的可读性。 + active: true + allowedComplexity: 14 + ignoreSingleWhenExpression: false + ignoreSimpleWhenEntries: false + ignoreNestingFunctions: false + ignoreLocalFunctions: false + nestingFunctions: + - 'also' + - 'apply' + - 'forEach' + - 'isNotNull' + - 'ifNull' + - 'let' + - 'run' + - 'use' + - 'with' + LabeledExpression: #报告已标记的表达式 + active: false + ignoredLabels: [] + LargeClass: #报告大型类 + active: true + allowedLines: 600 + LongMethod: #报告大方法 + active: true + allowedLines: 60 + LongParameterList: #报告参数超过特定阈值的函数和构造函数。 + active: true + allowedFunctionParameters: 6 + allowedConstructorParameters: 15 + ignoreDefaultParameters: false + ignoreDataClasses: true + ignoreAnnotatedParameter: [] + MethodOverloading: #报告经常重载的方法 + active: false + allowedOverloads: 6 + NamedArguments: #报告参数超过某个阈值且全部未命名的函数调用。参数过多的调用更难理解,因此命名参数会有所帮助。 + active: false + allowedArguments: 3 + ignoreArgumentsMatchingNames: false + NestedBlockDepth: #报告函数中嵌套深度过大 + active: true + allowedDepth: 4 + NestedScopeFunctions: #避免嵌套作用域函数 + active: false + allowedDepth: 1 + functions: + - 'kotlin.apply' + - 'kotlin.run' + - 'kotlin.with' + - 'kotlin.let' + - 'kotlin.also' + ReplaceSafeCallChainWithRun: #不可为null的类型上的安全调用链是冗余的,可以通过将冗余的安全调用封装在run{}块中来删除 {xxx?.run} + active: false + StringLiteralDuplication: #规则检测并报告重复的字符串文字 + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + allowedDuplications: 2 + ignoreAnnotation: true + allowedWithLengthLessThan: 5 + ignoreStringsRegex: '$^' + TooManyFunctions: #此规则报告包含过多函数的文件、类、接口、对象和枚举。每个元素可以配置有不同的阈值。 + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + allowedFunctionsPerFile: 11 + allowedFunctionsPerClass: 11 + allowedFunctionsPerInterface: 11 + allowedFunctionsPerObject: 11 + allowedFunctionsPerEnum: 11 + ignoreDeprecated: false + ignorePrivate: false + ignoreOverridden: false + +#协程规则集分析代码中潜在的协程问题。 +coroutines: + active: true + GlobalCoroutineUsage: + active: false + InjectDispatcher: #始终使用依赖项注入来注入调度器,以便于测试 + active: true + dispatcherNames: + - 'IO' + - 'Default' + - 'Unconfined' + RedundantSuspendModifier: #suspend修饰符只能在需要的地方使用,否则该函数只能从其他挂起函数中使用。这不必要地限制了函数的使用,应该通过删除不需要的suspend修饰符来避免 + active: true + SleepInsteadOfDelay: #报告Thread.sleep在挂起函数和协同程序块中的使用情况。由于协程的轻量级性质,一个线程可以同时包含多个协程,因此如果一个协程调用thread.sleep,它可能会停止执行不相关的协程,并导致不可预测的行为。 + active: true + SuspendFunSwallowedCancellation: #不应在runCatching的lambda块内部调用suspend函数 + active: false + SuspendFunWithCoroutineScopeReceiver: #将CoroutineScope用作接收器的挂起函数不应标记为挂起。 + active: false + SuspendFunWithFlowReturnType: #从kotlin.coroutines.Flow返回Flow的函数不应标记为挂起,简单地调用一个返回Flow的函数的行为不应该有任何副作用。只有当针对返回的Flow开始收集时,才应该实际完成工作。 + active: true + +#空块规则集包含将报告应避免的空代码块的规则。 +empty-blocks: + active: true + EmptyCatchBlock: #报告空的捕获块。空的catch块表示异常被忽略而未被处理 + active: true + allowedExceptionNameRegex: '_|(ignore|expected).*' + EmptyClassBlock: #报告空类。空的代码块没有任何作用,应该删除 + active: true + EmptyDefaultConstructor: #报告空的默认构造函数。空的代码块没有任何作用,应该删除 + active: true + EmptyDoWhileBlock: #报告空的do/while循环。空的代码块没有任何作用,应该删除 + active: true + EmptyElseBlock: #报告为空的else块。空的代码块没有任何作用,应该删除 + active: true + EmptyFinallyBlock: #报告为空的finally块。空代码块没有任何作用,应该删除 + active: true + EmptyForBlock: #报告为空的for块。空代码块没有任何作用,应该删除 + active: true + EmptyFunctionBlock: #报告为空的方法块。空代码块没有任何作用,应该删除 + active: true + ignoreOverridden: false + EmptyIfBlock: #报告为空的if块。空代码块没有任何作用,应该删除 + active: true + EmptyInitBlock: #报告为空的init块。空代码块没有任何作用,应该删除 + active: true + EmptyKotlinFile: #报告为空的kotlin文件。空代码块没有任何作用,应该删除 + active: true + EmptySecondaryConstructor: #报告为空的辅助构造函数。空代码块没有任何作用,应该删除 + active: true + EmptyTryBlock: #报告为空的try块。空代码块没有任何作用,应该删除 + active: true + EmptyWhenBlock: #报告为空的when块。空代码块没有任何作用,应该删除 + active: true + EmptyWhileBlock: #报告为空的while块。空代码块没有任何作用,应该删除 + active: true + +exceptions: + active: true + ExceptionRaisedInUnexpectedLocation: #此规则报告从不应引发异常的函数。如果存在引发异常的函数,则会报告该函数。默认情况下,此规则检查toString、hashCode、equals和finalize。此规则可通过methodNames配置进行配置 + active: true + methodNames: + - 'equals' + - 'finalize' + - 'hashCode' + - 'toString' + InstanceOfCheckForException: #此规则报告通过is检查或强制转换检查异常类型的捕获块。代码应该使用多个catch块,而不是捕获一般的异常类型,然后检查特定的异常类型。然后,这些捕获块应该捕获特定的异常 + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + NotImplementedDeclaration: #此规则报告引发的所有NotImplementedError类型的异常。它还报告所有TODO(..)函数。这表明功能仍在开发中,无法正常工作。这两种声明都只能作为临时声明,不应放入生产环境中 + active: false + ObjectExtendsThrowable: # + active: false + PrintStackTrace: + active: true + RethrowCaughtException: + active: true + ReturnFromFinally: + active: true + ignoreLabeled: false + SwallowedException: + active: true + ignoredExceptionTypes: + - 'InterruptedException' + - 'MalformedURLException' + - 'NumberFormatException' + - 'ParseException' + allowedExceptionNameRegex: '_|(ignore|expected).*' + ThrowingExceptionFromFinally: + active: true + ThrowingExceptionInMain: + active: false + ThrowingExceptionsWithoutMessageOrCause: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + exceptions: + - 'ArrayIndexOutOfBoundsException' + - 'Exception' + - 'IllegalArgumentException' + - 'IllegalMonitorStateException' + - 'IllegalStateException' + - 'IndexOutOfBoundsException' + - 'NullPointerException' + - 'RuntimeException' + - 'Throwable' + ThrowingNewInstanceOfSameException: + active: true + TooGenericExceptionCaught: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + exceptionNames: + - 'ArrayIndexOutOfBoundsException' + - 'Error' + - 'Exception' + - 'IllegalMonitorStateException' + - 'IndexOutOfBoundsException' + - 'NullPointerException' + - 'RuntimeException' + - 'Throwable' + allowedExceptionNameRegex: '_|(ignore|expected).*' + TooGenericExceptionThrown: + active: true + exceptionNames: + - 'Error' + - 'Exception' + - 'RuntimeException' + - 'Throwable' + +naming: + active: true + BooleanPropertyNaming: + active: false + allowedPattern: '^(is|has|are)' + ClassNaming: + active: true + classPattern: '[A-Z][a-zA-Z0-9]*' + ConstructorParameterNaming: + active: true + parameterPattern: '[a-z][A-Za-z0-9]*' + privateParameterPattern: '[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + EnumNaming: + active: true + enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' + ForbiddenClassName: + active: false + forbiddenName: [] + FunctionNameMaxLength: + active: false + maximumFunctionNameLength: 30 + FunctionNameMinLength: + active: false + minimumFunctionNameLength: 3 + FunctionNaming: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + functionPattern: '[a-z][a-zA-Z0-9]*' + excludeClassPattern: '$^' + FunctionParameterNaming: + active: true + parameterPattern: '[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + InvalidPackageDeclaration: + active: true + rootPackage: '' + requireRootInDeclaration: false + LambdaParameterNaming: + active: false + parameterPattern: '[a-z][A-Za-z0-9]*|_' + MatchingDeclarationName: + active: true + mustBeFirst: true + multiplatformTargets: + - 'ios' + - 'android' + - 'js' + - 'jvm' + - 'native' + - 'iosArm64' + - 'iosX64' + - 'macosX64' + - 'mingwX64' + - 'linuxX64' + MemberNameEqualsClassName: + active: true + ignoreOverridden: true + NoNameShadowing: + active: true + NonBooleanPropertyPrefixedWithIs: + active: false + ObjectPropertyNaming: + active: true + constantPattern: '[A-Za-z][_A-Za-z0-9]*' + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' + PackageNaming: + active: true + packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' + TopLevelPropertyNaming: + active: true + constantPattern: '[A-Z][_A-Z0-9]*' + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' + VariableMaxLength: + active: false + maximumVariableNameLength: 64 + VariableMinLength: + active: false + minimumVariableNameLength: 1 + VariableNaming: + active: true + variablePattern: '[a-z][A-Za-z0-9]*' + privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + +performance: + active: true + ArrayPrimitive: + active: true + CouldBeSequence: + active: false + allowedOperations: 2 + ForEachOnRange: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + SpreadOperator: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + UnnecessaryPartOfBinaryExpression: + active: false + UnnecessaryTemporaryInstantiation: + active: true + +potential-bugs: + active: true + AvoidReferentialEquality: + active: true + forbiddenTypePatterns: + - 'kotlin.String' + CastNullableToNonNullableType: + active: false + ignorePlatformTypes: true + CastToNullableType: + active: false + CharArrayToStringCall: + active: false + Deprecation: + active: false + DontDowncastCollectionTypes: + active: false + DoubleMutabilityForCollection: + active: true + mutableTypes: + - 'kotlin.collections.MutableList' + - 'kotlin.collections.MutableMap' + - 'kotlin.collections.MutableSet' + - 'java.util.ArrayList' + - 'java.util.LinkedHashSet' + - 'java.util.HashSet' + - 'java.util.LinkedHashMap' + - 'java.util.HashMap' + ElseCaseInsteadOfExhaustiveWhen: + active: false + ignoredSubjectTypes: [] + EqualsAlwaysReturnsTrueOrFalse: + active: true + EqualsWithHashCodeExist: + active: true + ExitOutsideMain: + active: false + ExplicitGarbageCollectionCall: + active: true + HasPlatformType: + active: true + IgnoredReturnValue: + active: true + restrictToConfig: true + returnValueAnnotations: + - 'CheckResult' + - '*.CheckResult' + - 'CheckReturnValue' + - '*.CheckReturnValue' + ignoreReturnValueAnnotations: + - 'CanIgnoreReturnValue' + - '*.CanIgnoreReturnValue' + returnValueTypes: + - 'kotlin.sequences.Sequence' + - 'kotlinx.coroutines.flow.*Flow' + - 'java.util.stream.*Stream' + ignoreFunctionCall: [] + ImplicitDefaultLocale: + active: true + ImplicitUnitReturnType: + active: false + allowExplicitReturnType: true + InvalidRange: + active: true + IteratorHasNextCallsNextMethod: + active: true + IteratorNotThrowingNoSuchElementException: + active: true + LateinitUsage: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + ignoreOnClassesPattern: '' + MapGetWithNotNullAssertionOperator: + active: true + MissingPackageDeclaration: + active: false + excludes: ['**/*.kts'] + NullCheckOnMutableProperty: + active: false + NullableToStringCall: + active: false + PropertyUsedBeforeDeclaration: + active: false + UnconditionalJumpStatementInLoop: + active: false + UnnecessaryNotNullCheck: + active: false + UnnecessaryNotNullOperator: + active: true + UnnecessarySafeCall: + active: true + UnreachableCatchBlock: + active: true + UnreachableCode: + active: true + UnsafeCallOnNullableType: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] + UnsafeCast: + active: true + UnusedUnaryOperator: + active: true + UselessPostfixExpression: + active: true + WrongEqualsTypeParameter: + active: true + +style: + active: true + AbstractClassCanBeConcreteClass: + active: true + AbstractClassCanBeInterface: + active: true + AlsoCouldBeApply: + active: false + BracesOnIfStatements: + active: false + singleLine: 'never' + multiLine: 'always' + BracesOnWhenStatements: + active: false + singleLine: 'necessary' + multiLine: 'consistent' + CanBeNonNullable: + active: false + CascadingCallWrapping: + active: false + includeElvis: true + ClassOrdering: + active: false + CollapsibleIfStatements: + active: false + DataClassContainsFunctions: + active: false + conversionFunctionPrefix: + - 'to' + allowOperators: false + DataClassShouldBeImmutable: + active: false + DestructuringDeclarationWithTooManyEntries: + active: true + maxDestructuringEntries: 3 + DoubleNegativeLambda: + active: false + negativeFunctions: + - reason: 'Use `takeIf` instead.' + value: 'takeUnless' + - reason: 'Use `all` instead.' + value: 'none' + negativeFunctionNameParts: + - 'not' + - 'non' + EqualsNullCall: + active: true + EqualsOnSignatureLine: + active: false + ExplicitCollectionElementAccessMethod: + active: false + ExplicitItLambdaParameter: + active: true + ExpressionBodySyntax: + active: false + includeLineWrapping: false + ForbiddenAnnotation: + active: false + annotations: + - reason: 'it is a java annotation. Use `Suppress` instead.' + value: 'java.lang.SuppressWarnings' + - reason: 'it is a java annotation. Use `kotlin.Deprecated` instead.' + value: 'java.lang.Deprecated' + - reason: 'it is a java annotation. Use `kotlin.annotation.MustBeDocumented` instead.' + value: 'java.lang.annotation.Documented' + - reason: 'it is a java annotation. Use `kotlin.annotation.Target` instead.' + value: 'java.lang.annotation.Target' + - reason: 'it is a java annotation. Use `kotlin.annotation.Retention` instead.' + value: 'java.lang.annotation.Retention' + - reason: 'it is a java annotation. Use `kotlin.annotation.Repeatable` instead.' + value: 'java.lang.annotation.Repeatable' + - reason: 'Kotlin does not support @Inherited annotation, see https://youtrack.jetbrains.com/issue/KT-22265' + value: 'java.lang.annotation.Inherited' + ForbiddenComment: + active: true + comments: + - reason: 'Forbidden FIXME todo marker in comment, please fix the problem.' + value: 'FIXME:' + - reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code.' + value: 'STOPSHIP:' + - reason: 'Forbidden TODO todo marker in comment, please do the changes.' + value: 'TODO:' + allowedPatterns: '' + ForbiddenImport: + active: false + imports: [] + forbiddenPatterns: '' + ForbiddenMethodCall: + active: false + methods: + - reason: 'print does not allow you to configure the output stream. Use a logger instead.' + value: 'kotlin.io.print' + - reason: 'println does not allow you to configure the output stream. Use a logger instead.' + value: 'kotlin.io.println' + ForbiddenSuppress: + active: false + rules: [] + ForbiddenVoid: + active: true + ignoreOverridden: false + ignoreUsageInGenerics: false + FunctionOnlyReturningConstant: + active: true + ignoreOverridableFunction: true + ignoreActualFunction: true + excludedFunctions: [] + LoopWithTooManyJumpStatements: + active: true + maxJumpCount: 1 + MagicNumber: + active: true + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts'] + ignoreNumbers: + - '-1' + - '0' + - '1' + - '2' + ignoreHashCodeFunction: true + ignorePropertyDeclaration: false + ignoreLocalVariableDeclaration: false + ignoreConstantDeclaration: true + ignoreCompanionObjectPropertyDeclaration: true + ignoreAnnotation: false + ignoreNamedArgument: true + ignoreEnums: false + ignoreRanges: false + ignoreExtensionFunctions: true + MandatoryBracesLoops: + active: false + MaxChainedCallsOnSameLine: + active: false + maxChainedCalls: 5 + MaxLineLength: + active: true + maxLineLength: 120 + excludePackageStatements: true + excludeImportStatements: true + excludeCommentStatements: false + excludeRawStrings: true + MayBeConstant: + active: true + ModifierOrder: + active: true + MultilineLambdaItParameter: + active: false + MultilineRawStringIndentation: + active: false + indentSize: 4 + trimmingMethods: + - 'trimIndent' + - 'trimMargin' + NestedClassesVisibility: + active: true + NewLineAtEndOfFile: + active: true + NoTabs: + active: false + NullableBooleanCheck: + active: false + ObjectLiteralToLambda: + active: true + OptionalAbstractKeyword: + active: true + OptionalUnit: + active: false + PreferToOverPairSyntax: + active: false + ProtectedMemberInFinalClass: + active: true + RangeUntilInsteadOfRangeTo: + active: false + RedundantExplicitType: + active: false + RedundantHigherOrderMapUsage: + active: true + RedundantVisibilityModifierRule: + active: false + ReturnCount: + active: true + max: 2 + excludedFunctions: + - 'equals' + excludeLabeled: false + excludeReturnFromLambda: true + excludeGuardClauses: false + SafeCast: + active: true + SerialVersionUIDInSerializableClass: + active: true + SpacingAfterPackageDeclaration: + active: false + StringShouldBeRawString: + active: false + maxEscapedCharacterCount: 2 + ignoredCharacters: [] + ThrowsCount: + active: true + max: 2 + excludeGuardClauses: false + TrailingWhitespace: + active: false + TrimMultilineRawString: + active: false + trimmingMethods: + - 'trimIndent' + - 'trimMargin' + UnderscoresInNumericLiterals: + active: false + acceptableLength: 4 + allowNonStandardGrouping: false + UnnecessaryAnnotationUseSiteTarget: + active: false + UnnecessaryApply: + active: true + UnnecessaryBackticks: + active: false + UnnecessaryBracesAroundTrailingLambda: + active: false + UnnecessaryFilter: + active: true + UnnecessaryInheritance: + active: true + UnnecessaryInnerClass: + active: false + UnnecessaryLet: + active: false + UnnecessaryParentheses: + active: false + allowForUnclearPrecedence: false + UnusedImport: + active: false + UnusedParameter: + active: true + allowedNames: 'ignored|expected' + UnusedPrivateClass: + active: true + UnusedPrivateMember: + active: true + allowedNames: '' + UnusedPrivateProperty: + active: true + allowedNames: '_|ignored|expected|serialVersionUID' + UseAnyOrNoneInsteadOfFind: + active: true + UseArrayLiteralsInAnnotations: + active: true + UseCheckNotNull: + active: true + UseCheckOrError: + active: true + UseDataClass: + active: false + allowVars: false + UseEmptyCounterpart: + active: false + UseIfEmptyOrIfBlank: + active: false + UseIfInsteadOfWhen: + active: false + ignoreWhenContainingVariableDeclaration: false + UseIsNullOrEmpty: + active: true + UseLet: + active: false + UseOrEmpty: + active: true + UseRequire: + active: true + UseRequireNotNull: + active: true + UseSumOfInsteadOfFlatMapSize: + active: false + UselessCallOnNotNull: + active: true + UtilityClassWithPublicConstructor: + active: true + VarCouldBeVal: + active: true + ignoreLateinitVar: false + WildcardImport: + active: true + excludeImports: + - 'java.util.*' \ No newline at end of file diff --git a/codequality/pmd.gradle b/codequality/pmd.gradle index 3a7aa35a78..359264c4ee 100644 --- a/codequality/pmd.gradle +++ b/codequality/pmd.gradle @@ -7,7 +7,7 @@ task pmd(type:Pmd){ ignoreFailures = false consoleOutput = true //filter路径 - ruleSetFiles = files("${pmdConfigPath}/custom-pmd-ruleset.xml") // todo 新增rules + ruleSetFiles = files("${pmdConfigPath}/custom-pmd-ruleset.xml") //新增rules ruleSets = [] //检测资源路径 source 'src/main/java','src/jinlvvan/java','src/driverm1/java' From d916ab0c99d0d8361f7ae4e9924372f636772ac8 Mon Sep 17 00:00:00 2001 From: jiaguofeng Date: Mon, 25 Sep 2023 16:52:14 +0800 Subject: [PATCH 02/24] =?UTF-8?q?[map-sdk]=E4=BF=AE=E6=94=B9=E9=94=9A?= =?UTF-8?q?=E7=82=B9=E6=8E=A7=E5=88=B6=E6=96=B9=E5=90=91bug=203.2.0.15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 396792636b..a8675a971e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -80,7 +80,7 @@ MOGO_LOCATION_VERSION=1.4.7.16 MOGO_TELEMATIC_VERSION=1.4.7.16 ######## MogoAiCloudSDK Version ######## # 自研地图 -MAP_SDK_VERSION=3.2.0.14 +MAP_SDK_VERSION=3.2.0.15 MAP_SDK_DATA_VERSION=1.0.0.3 MAP_SDK_OPERATION_VERSION=1.1.4.1 # websocket From d22817e14e1e7de2ba1be5b97d2d6dd29ab6ebd8 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 25 Sep 2023 17:20:43 +0800 Subject: [PATCH 03/24] [3.4.0-map-sdk] rules change --- codequality/detekt.yml | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/codequality/detekt.yml b/codequality/detekt.yml index 79fe7453d9..3a76561338 100644 --- a/codequality/detekt.yml +++ b/codequality/detekt.yml @@ -245,16 +245,16 @@ exceptions: excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] NotImplementedDeclaration: #此规则报告引发的所有NotImplementedError类型的异常。它还报告所有TODO(..)函数。这表明功能仍在开发中,无法正常工作。这两种声明都只能作为临时声明,不应放入生产环境中 active: false - ObjectExtendsThrowable: # + ObjectExtendsThrowable: #避免抛出单例Throwable active: false - PrintStackTrace: + PrintStackTrace: #打印堆栈 active: true - RethrowCaughtException: + RethrowCaughtException: #重新抛出异常 active: true - ReturnFromFinally: + ReturnFromFinally: # finally return active: true ignoreLabeled: false - SwallowedException: + SwallowedException: #报告所有捕获异常且未正确传递(例如作为原因)到新引发异常的实例 active: true ignoredExceptionTypes: - 'InterruptedException' @@ -262,11 +262,11 @@ exceptions: - 'NumberFormatException' - 'ParseException' allowedExceptionNameRegex: '_|(ignore|expected).*' - ThrowingExceptionFromFinally: + ThrowingExceptionFromFinally: #报告从finally块抛出异常 active: true - ThrowingExceptionInMain: + ThrowingExceptionInMain: #报告在主方法中引发的所有异常。只有当异常可以由“更高”的函数处理时,才应该抛出异常 active: false - ThrowingExceptionsWithoutMessageOrCause: + ThrowingExceptionsWithoutMessageOrCause: #报告在没有参数或进一步描述的情况下抛出的所有异常 active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] exceptions: @@ -279,9 +279,9 @@ exceptions: - 'NullPointerException' - 'RuntimeException' - 'Throwable' - ThrowingNewInstanceOfSameException: + ThrowingNewInstanceOfSameException: #异常不应封装在同一异常类型中,然后重新抛出。更喜欢用更有意义的异常类型包装异常 active: true - TooGenericExceptionCaught: + TooGenericExceptionCaught: #规则为类型过于通用的异常报告捕获块。最好捕获当前处理的案例的特定异常,避免扩大区域 active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] exceptionNames: @@ -294,7 +294,7 @@ exceptions: - 'RuntimeException' - 'Throwable' allowedExceptionNameRegex: '_|(ignore|expected).*' - TooGenericExceptionThrown: + TooGenericExceptionThrown: #规则报告类型过于通用的抛出异常。对于当前发生的情况,最好抛出特定的异常 active: true exceptionNames: - 'Error' @@ -391,29 +391,30 @@ naming: performance: active: true - ArrayPrimitive: + ArrayPrimitive: #使用Array<Primitive>会导致隐含拳击和性能打击。更喜欢使用Kotlin专用的数组实例 active: true - CouldBeSequence: + CouldBeSequence: #由于每个调用都会创建一个新的列表,因此长链的收集操作将带来性能损失。请考虑使用序列 active: false allowedOperations: 2 - ForEachOnRange: + ForEachOnRange: #在一个范围内使用forEach可能会产生巨大的性能成本。因此,在大多数情况下,应该使用简单的for循环 (for example: {(1..10).forEach}) active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] - SpreadOperator: + SpreadOperator: #在大多数情况下,使用排列运算符会导致在调用方法之前创建数组的完整副本。这会带来非常高的性能损失 active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] - UnnecessaryPartOfBinaryExpression: + UnnecessaryPartOfBinaryExpression: #仅在表达式仅使用以下运算符之一||或&&的情况下验证二进制表达式 active: false - UnnecessaryTemporaryInstantiation: + UnnecessaryTemporaryInstantiation: #将基元类型转换为字符串时,请避免使用临时对象。与直接使用基元类型相比,这会降低性能。若要解决此问题,请删除包装类型 active: true +#潜在错误规则集提供了检测潜在错误的规则。 potential-bugs: active: true - AvoidReferentialEquality: + AvoidReferentialEquality: #检查平等 active: true forbiddenTypePatterns: - 'kotlin.String' - CastNullableToNonNullableType: + CastNullableToNonNullableType: #可空强转null active: false ignorePlatformTypes: true CastToNullableType: From 6f96d612c67fbb6650be7f36767c62aac7af69cc Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 25 Sep 2023 19:02:30 +0800 Subject: [PATCH 04/24] [3.4.0-map-sdk] rules --- codequality/detekt.yml | 44 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/codequality/detekt.yml b/codequality/detekt.yml index 3a76561338..056a7d0ef4 100644 --- a/codequality/detekt.yml +++ b/codequality/detekt.yml @@ -417,15 +417,15 @@ potential-bugs: CastNullableToNonNullableType: #可空强转null active: false ignorePlatformTypes: true - CastToNullableType: + CastToNullableType: #将不安全的强制转换报告为可为null的类型。作为字符串?未填充,可能被误用为安全类型转换(如?字符串) active: false CharArrayToStringCall: active: false Deprecation: active: false - DontDowncastCollectionTypes: + DontDowncastCollectionTypes: #检查集合向下类型转换,建议方法转换({list as MutableList} convert : {list.toMutableList()}) active: false - DoubleMutabilityForCollection: + DoubleMutabilityForCollection: #MutableState可变var,不可变建议val active: true mutableTypes: - 'kotlin.collections.MutableList' @@ -436,19 +436,21 @@ potential-bugs: - 'java.util.HashSet' - 'java.util.LinkedHashMap' - 'java.util.HashMap' - ElseCaseInsteadOfExhaustiveWhen: + ElseCaseInsteadOfExhaustiveWhen: #当表达式包含else大小写时,即使它们有一组详尽的大小写,该规则也会报告 active: false ignoredSubjectTypes: [] - EqualsAlwaysReturnsTrueOrFalse: + EqualsAlwaysReturnsTrueOrFalse: #报告始终返回true或false的equals()方法。 active: true - EqualsWithHashCodeExist: + EqualsWithHashCodeExist: #当一个类重写equals()方法时,它也应该重写hashCode()方法 active: true - ExitOutsideMain: + ExitOutsideMain: #报告主函数之外使用System.exit()、Runtime.exit()、Runtime.holt()和Kotlin的exitProcess()时的使用情况 active: false - ExplicitGarbageCollectionCall: + ExplicitGarbageCollectionCall: #报告所有显式触发垃圾回收器的调用。代码应该独立于垃圾收集器工作,并且不应该要求在某些时间点触发GC。 active: true - HasPlatformType: + HasPlatformType: #必须在公共API中显式声明平台类型,以防止出现意外错误 active: true + + #此规则对使用@CheckReturnValue或@CheckResult注释的函数返回值但未以任何方式使用该值的实例发出警告Kotlin编译器通常不会对这种情况发出警告,所以这就是该规则背后的基本原理。 IgnoredReturnValue: active: true restrictToConfig: true @@ -465,31 +467,31 @@ potential-bugs: - 'kotlinx.coroutines.flow.*Flow' - 'java.util.stream.*Stream' ignoreFunctionCall: [] - ImplicitDefaultLocale: - active: true - ImplicitUnitReturnType: + ImplicitDefaultLocale: #格式化字符串或执行大小写转换时,更喜欢显式传递[java.util.Locale],而不是使用隐式默认值 + active: false + ImplicitUnitReturnType: #使用表达式语句的函数具有隐式返回类型 active: false allowExplicitReturnType: true - InvalidRange: + InvalidRange: #报告为空的范围 active: true - IteratorHasNextCallsNextMethod: + IteratorHasNextCallsNextMethod: #验证Iterator接口的实现。Iterator实现的hasNext()方法不应该有任何副作用 active: true - IteratorNotThrowingNoSuchElementException: + IteratorNotThrowingNoSuchElementException: #报告在next()方法的实现中不抛出NoSuchElementException的Iterator接口的实现。当没有更多的元素要返回时,迭代器应该抛出NoSuchElementException active: true - LateinitUsage: + LateinitUsage: #报告Late-init修饰符的用法。 active: false excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] ignoreOnClassesPattern: '' - MapGetWithNotNullAssertionOperator: + MapGetWithNotNullAssertionOperator: #使用非null断言运算符报告对map访问方法map[]或map.get()的调用!!。这可能会导致NullPointerException active: true - MissingPackageDeclaration: + MissingPackageDeclaration: #当缺少包声明时报告 active: false excludes: ['**/*.kts'] - NullCheckOnMutableProperty: + NullCheckOnMutableProperty: #规则已弃用,因为编译器默认执行此检查,当主题是枚举或密封类时,以及当表达式用作语句时,启用此规则可标记未检查是否覆盖所有事例的表达式 active: false - NullableToStringCall: + NullableToStringCall: #报告对可变属性的null检查,因为这些属性的值可以在执行if语句后更改,从而使null检查无效 active: false - PropertyUsedBeforeDeclaration: + PropertyUsedBeforeDeclaration: # active: false UnconditionalJumpStatementInLoop: active: false From 4798cbfa82cf5cdcca3a476c38e82e48aa6caaa3 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 25 Sep 2023 20:19:45 +0800 Subject: [PATCH 05/24] [3.4.0-map-sdk] rules --- codequality/detekt.gradle | 10 +++++---- codequality/detekt.yml | 43 ++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/codequality/detekt.gradle b/codequality/detekt.gradle index 39fbca4670..ec3d539fd0 100644 --- a/codequality/detekt.gradle +++ b/codequality/detekt.gradle @@ -1,4 +1,6 @@ -apply plugin: 'io.gitlab.arturbosch.detekt' +plugins { + id("io.gitlab.arturbosch.detekt") version "1.21.0" +} def pmdConfigPath = rootProject.file("codequality").path @@ -6,9 +8,9 @@ detekt{ //将配置文件应用于detekt的默认配置文件之上 buildUponDefaultConfig = true source = files( - "src/main/kotlin", - "src/jinlvvan/kotlin", - "src/driverm1/kotlin" + "src/main/java", + "src/jinlvvan/java", + "src/driverm1/java" ) //规则集 config.setFrom("${pmdConfigPath}/detekt.yml") diff --git a/codequality/detekt.yml b/codequality/detekt.yml index 056a7d0ef4..73af812f49 100644 --- a/codequality/detekt.yml +++ b/codequality/detekt.yml @@ -487,36 +487,37 @@ potential-bugs: MissingPackageDeclaration: #当缺少包声明时报告 active: false excludes: ['**/*.kts'] - NullCheckOnMutableProperty: #规则已弃用,因为编译器默认执行此检查,当主题是枚举或密封类时,以及当表达式用作语句时,启用此规则可标记未检查是否覆盖所有事例的表达式 + NullCheckOnMutableProperty: #报告对可变属性的null检查,因为这些属性的值可以在执行if语句后更改,从而使null检查无效 active: false - NullableToStringCall: #报告对可变属性的null检查,因为这些属性的值可以在执行if语句后更改,从而使null检查无效 + NullableToStringCall: #使用可能返回字符串“null”的可为null的接收器报告toString()调用 active: false - PropertyUsedBeforeDeclaration: # + PropertyUsedBeforeDeclaration: #报告在声明之前使用的属性 active: false - UnconditionalJumpStatementInLoop: + UnconditionalJumpStatementInLoop: #报告包含跳转语句的循环,这些语句在任何条件下都会跳转 active: false - UnnecessaryNotNullCheck: + UnnecessaryNotNullCheck: #使用requireNotNull或checkNotNull报告用户可以删除的不必要的非null检查。 active: false - UnnecessaryNotNullOperator: + UnnecessaryNotNullOperator: #报告用户可以删除的不必要的非null运算符用法(!!) active: true - UnnecessarySafeCall: + UnnecessarySafeCall: #报告用户可以删除的不必要的非null运算符用法(?) active: true - UnreachableCatchBlock: + UnreachableCatchBlock: #报告无法访问的捕获块。如果在上面的块中已经捕获到异常,则捕获块可能无法访问(Exception or Throwable)catch顺序 active: true - UnreachableCode: + UnreachableCode: #报告无法访问的代码。代码可能无法访问,因为它位于return、throw、continue或break表达式后面 active: true - UnsafeCallOnNullableType: + UnsafeCallOnNullableType: #报告对可为null的类型的不安全调用 active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] - UnsafeCast: + UnsafeCast: #报告不安全的强制转换 active: true - UnusedUnaryOperator: + UnusedUnaryOperator: #检测未使用的一元运算符 active: true - UselessPostfixExpression: + UselessPostfixExpression: #报告未使用因而不必要的后缀表达式(++,--) active: true - WrongEqualsTypeParameter: + WrongEqualsTypeParameter: #报告接受错误类型参数的equals()方法 active: true +#{link https://detekt.dev/docs/rules/style#explicititlambdaparameter} style: active: true AbstractClassCanBeConcreteClass: @@ -550,7 +551,7 @@ style: DataClassShouldBeImmutable: active: false DestructuringDeclarationWithTooManyEntries: - active: true + active: false maxDestructuringEntries: 3 DoubleNegativeLambda: active: false @@ -591,7 +592,7 @@ style: - reason: 'Kotlin does not support @Inherited annotation, see https://youtrack.jetbrains.com/issue/KT-22265' value: 'java.lang.annotation.Inherited' ForbiddenComment: - active: true + active: false comments: - reason: 'Forbidden FIXME todo marker in comment, please fix the problem.' value: 'FIXME:' @@ -668,7 +669,7 @@ style: trimmingMethods: - 'trimIndent' - 'trimMargin' - NestedClassesVisibility: + NestedClassesVisibility: #嵌套类从父类继承其可见性,通常用于实现嵌套在其中的类的本地功能。这些嵌套类的可见性不能高于其父类 active: true NewLineAtEndOfFile: active: true @@ -676,7 +677,7 @@ style: active: false NullableBooleanCheck: active: false - ObjectLiteralToLambda: + ObjectLiteralToLambda: #除了实现单个方法之外什么都不做的匿名对象可以用作lambda。 active: true OptionalAbstractKeyword: active: true @@ -694,7 +695,7 @@ style: active: true RedundantVisibilityModifierRule: active: false - ReturnCount: + ReturnCount: #在一个函数中有许多出口点可能会造成混乱,并影响代码的可读性。 active: true max: 2 excludedFunctions: @@ -712,7 +713,7 @@ style: active: false maxEscapedCharacterCount: 2 ignoredCharacters: [] - ThrowsCount: + ThrowsCount: #限制函数中抛出语句的数量,函数应该有明确的throw语句 active: true max: 2 excludeGuardClauses: false @@ -737,7 +738,7 @@ style: active: false UnnecessaryFilter: active: true - UnnecessaryInheritance: + UnnecessaryInheritance: #此规则报告不必要的超类型 active: true UnnecessaryInnerClass: active: false From 8d2cd6799697fb43675c49b8e7a5680855c3c8e8 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Tue, 26 Sep 2023 11:10:15 +0800 Subject: [PATCH 06/24] [3.4.0-map-sdk] fix bug --- build.gradle | 2 +- codequality/detekt.gradle | 18 ++++++++++++++++-- .../core/MogoTrafficLightManager.kt | 3 --- gradle/ext.gradle | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index fb29e29960..e4da99cf9b 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ buildscript { classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18' classpath "com.mogo.sticky:service:${plugin_version}" classpath "io.github.knight-zxw:lancet-plugin:${lancetx_plugin_version}" - classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.21.0" + classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.15.0" classpath 'com.mogo.cloud:matrix:1.0.0' // classpath 'com.bytedance.btrace:rhea-gradle-plugin:2.0.0' } diff --git a/codequality/detekt.gradle b/codequality/detekt.gradle index ec3d539fd0..b6f417e01b 100644 --- a/codequality/detekt.gradle +++ b/codequality/detekt.gradle @@ -1,5 +1,5 @@ plugins { - id("io.gitlab.arturbosch.detekt") version "1.21.0" + id("io.gitlab.arturbosch.detekt") version "1.15.0" } def pmdConfigPath = rootProject.file("codequality").path @@ -8,9 +8,12 @@ detekt{ //将配置文件应用于detekt的默认配置文件之上 buildUponDefaultConfig = true source = files( + "src/main/kotlin", "src/main/java", "src/jinlvvan/java", - "src/driverm1/java" + "src/jinlvvan/kotlin", + "src/driverm1/java", + "src/driverm1/kotlin" ) //规则集 config.setFrom("${pmdConfigPath}/detekt.yml") @@ -27,6 +30,10 @@ detekt{ // ignoredVariants = ["productionRelease"] } +dependencies { + detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.21.0" +} + tasks.detekt.jvmTarget = "1.8" tasks.named("detekt").configure { @@ -36,4 +43,11 @@ tasks.named("detekt").configure { html.required.set(true) html.outputLocation.set(destination) } +} + +project.afterEvaluate { + if (tasks.findByName("preBuild") != null) { + project.preBuild.dependsOn tasks.findByName("detekt") + println("project.preBuild.dependsOn tasks.findByName(\"detekt\")") + } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/trafficlight/core/MogoTrafficLightManager.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/trafficlight/core/MogoTrafficLightManager.kt index 0132da1f0b..9162f89d09 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/trafficlight/core/MogoTrafficLightManager.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/trafficlight/core/MogoTrafficLightManager.kt @@ -150,9 +150,6 @@ class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener, private fun outOfCrossRange(){ CallerLogger.d(M_V2X + TAG, "离开路口 , inRange:$inRange") - if(!inRange){ - return - } CallerTrafficLightListenerManager.invokeEnterCrossRoad(false) inRange = false trafficLightResult = null diff --git a/gradle/ext.gradle b/gradle/ext.gradle index 2337daae66..7ebb4b74a6 100644 --- a/gradle/ext.gradle +++ b/gradle/ext.gradle @@ -1,5 +1,5 @@ ext { - gradle_version = '3.5.3' + gradle_version = '4.0.1' kotlin_plugin_version = '1.5.30' plugin_version = '10.0.0_mogo' service_chain_version = '5.3.6' From aebb330e89301bee13e92ea535733d586afde2f5 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Tue, 26 Sep 2023 15:46:06 +0800 Subject: [PATCH 07/24] [3.4.0-map-sdk] update and new func of code quality --- build.gradle | 12 +- codequality/code_inspect.gradle | 24 +++ codequality/code_inspect_increment.gradle | 186 ++++++++++++++++++++++ codequality/detekt.gradle | 85 +++++----- config.gradle | 6 + 5 files changed, 263 insertions(+), 50 deletions(-) create mode 100644 codequality/code_inspect.gradle create mode 100644 codequality/code_inspect_increment.gradle diff --git a/build.gradle b/build.gradle index e4da99cf9b..190f5f0714 100644 --- a/build.gradle +++ b/build.gradle @@ -52,7 +52,6 @@ buildscript { } allprojects { - apply from: rootProject.file('codequality/pmd.gradle') repositories { mavenLocal() maven { url 'http://nexus.zhidaoauto.com/repository/maven-releases/' } @@ -73,6 +72,17 @@ allprojects { } google() } + + if (isCodeInspectEnable ) { + def basePath = new File(codequality, 'code_inspect_increment.gradle').path + apply from: "$basePath" + def pmdPath = new File(codequality, 'pmd.gradle').path + apply from: "$pmdPath" + def detektPath = new File(codequality, 'detekt.gradle').path + apply from: "$detektPath" + def codeInspectPath = new File(codequality, 'code_inspect.gradle').path + apply from: "$codeInspectPath" + } } task clean(type: Delete) { diff --git a/codequality/code_inspect.gradle b/codequality/code_inspect.gradle new file mode 100644 index 0000000000..ab96a4c056 --- /dev/null +++ b/codequality/code_inspect.gradle @@ -0,0 +1,24 @@ +task runCodeInspect { + group = "codeInspect" + description = "静态代码检查,统一触发pmd detekt lint任务" +} + +project.afterEvaluate { + bindTask("pmd", "runCodeInspect") + bindTask("detekt", "runCodeInspect") +} + +/** + * 绑定任务 + * @param taskName 任务名称 + * @param targetTaskName 被绑定的任务名称 + * @param action taskName指定的任务执行完成后的回调 + */ +def bindTask(String taskName, String targetTaskName) { + def task = project.tasks.findByName(taskName) + if (task != null) { + logger.lifecycle("${task} will be run") + def targetTask = project.tasks.findByName(targetTaskName) + targetTask.finalizedBy(task) + } +} diff --git a/codequality/code_inspect_increment.gradle b/codequality/code_inspect_increment.gradle new file mode 100644 index 0000000000..4b5e517f92 --- /dev/null +++ b/codequality/code_inspect_increment.gradle @@ -0,0 +1,186 @@ +ext { + //存储增量的Java文件,给pmd使用 + commitJavaFiles = new ArrayList() + //存储增量的kotlin文件,给detekt使用 + commitKotlinFiles = new ArrayList() + commitAuthor = "" + appVersionName = "" +} + +/** + * 增量开关 + */ +def isIncrement = false + +/** + * 通过cmd命令获取结果值 + * @return string 结果值 + */ +def getResultFromCmd(String cmd) { + logger.lifecycle("${project.name} cmd:$cmd") + def out = new ByteArrayOutputStream() + if (System.properties['os.name'].toLowerCase().contains('windows')) { + project.exec { + ExecSpec execSpec -> + executable 'cmd' + args '/c', "$cmd" + standardOutput = out + }.assertNormalExitValue() + } else { + project.exec { + ExecSpec execSpec -> + executable 'bash' + args '-c', "$cmd" + standardOutput = out + }.assertNormalExitValue() + } + return out.toString().trim() +} + +/** + * 获取提交作者 + * @return 提交作者 + */ +def getCommitAuthor() { + def commitAuthor = "" +// if (isCiServer()) { +// commitAuthor = "${System.env.CI_COMMIT_AUTHOR}" +// commitAuthor = commitAuthor.substring(0, commitAuthor.indexOf('<')).trim() +// } else { + commitAuthor = getResultFromCmd("git config --get user.name") +// } + return commitAuthor +} + +/** + * 获取提交 sha,用于 git diff 出增量文件,其它项目仓库,这个方法需要更改实现 + * @return 提交 sha + */ +def getCommitTargetSha() { + //目前这个仓库只能根据上一个merge节点,进行代码增量检测 + def commitTargetSha = getResultFromCmd("git log --max-count=1 --pretty=%H --merges") + return commitTargetSha +} + +/** + * 获取提交文件,只包含.java和.kt的文件 + * @return 文件相对路径数组 + */ +def getCommitFiles() { + def commitTargetSha = getCommitTargetSha() + def commitSha = getResultFromCmd("git log --max-count=1 --pretty=%H") + def commitAuthor = getCommitAuthor() + def cmd = "git log --name-only --author=$commitAuthor --pretty=\"format:\" $commitTargetSha..$commitSha" + def result = getResultFromCmd(cmd) + def projectStartPath = getProjectStartPath() + logger.lifecycle("projectStartPath=$projectStartPath") + if (result != null && result.trim().length() > 0) { + def files = result.readLines() + .findAll { it.startsWith("${projectStartPath}") && isFilePathValid(it) }.toArray() + return files.toUnique() + } + return null +} + +/** + * 判断文件路径是否合理 + * @param path 文件路径 + * @return true合理,否则不合理 + */ +static def isFilePathValid(String path) { + return (path.endsWith('.kt') || path.endsWith('.java') || path.endsWith('.xml') || path.endsWith('.png')) && !path.contains('/test/') && !path.contains('/androidTest/') && !path.contains('/generated/') +} + +/** + * 获取src目录下的所有文件,只包含.java和.kt的文件 + * @return 文件相对路径数组 + */ +def getAllFiles() { + def fileCollection = project.files("src") + if (fileCollection == null) { + return null + } + def files = fileCollection.asFileTree.getFiles() + def iterator = files.iterator() + def allFiles = new ArrayList(files.size()) + while (iterator.hasNext()) { + File file = iterator.next() + def path = getProjectStartPath() + File.separator + project.relativePath(file.path) + if (path != null && isFilePathValid(path)) { + allFiles.add(path) + } + } + return allFiles.toArray(new Object[allFiles.size()]) +} + +/** + * 获取项目名称,如gradleengine,framework/asmbase + * @return 项目名称 + */ +def getProjectStartPath() { + def projectRelativePath = project.relativePath(project.path).replaceAll(':', '/') + return projectRelativePath.substring(1) +} + +/** + * 存储提交文件 + * @param commitFiles 提交文件 + */ +def saveCommitFiles(Object[] commitFiles) { + //commitFiles 是对象 + def lintBuildDir = new File(project.buildDir, "code_inspect") + if (!lintBuildDir.exists()) { + lintBuildDir.mkdirs() + } + def changedFile = new File(lintBuildDir, "commit_files.txt") + def fileOutputStream = new FileOutputStream(changedFile) + def rootProjectPath = project.rootProject.rootDir.path + File.separator + //存储绝对路径 + for (int i = 0; i < commitFiles.length; i++) { + def commitFile = commitFiles[i].toString() + fileOutputStream.write((rootProjectPath + commitFile).getBytes("utf-8")) + if (i != commitFiles.length - 1) + fileOutputStream.write("\n".getBytes("utf-8")) + } + fileOutputStream.flush() + fileOutputStream.close() + logger.lifecycle("Save Commit Files In: ${changedFile.path} \n$commitFiles") +} + + +task runCodeInspectIncrement { + group = "codeInspect" + description = "存储增量文件" + def commitJavaFiles = new ArrayList() + def commitKotlinFiles = new ArrayList() + + def commitFiles = new Object[0] + if (isIncrement) { + commitFiles = getCommitFiles() + } else { + commitFiles = getAllFiles() + } + saveCommitFiles(commitFiles) + if (commitFiles != null && commitFiles.length > 0) { + def projectStartPath = getProjectStartPath() + for (String s : commitFiles) { + def commitFile = s.toString().trim() + if (commitFile.endsWith('.kt')) { + commitKotlinFiles.add(commitFile.substring(projectStartPath.length() + 1)) + } else if (commitFile.endsWith('.java')) { + commitJavaFiles.add(commitFile.substring(projectStartPath.length() + 1)) + } + } + } + if (!commitKotlinFiles.isEmpty()) { + logger.lifecycle("${project.name} commitKotlinFiles:$commitKotlinFiles") + } + if (!commitJavaFiles.isEmpty()) { + logger.lifecycle("${project.name} commitJavaFiles:$commitJavaFiles") + } + project.setProperty("commitKotlinFiles", commitKotlinFiles) + project.setProperty("commitJavaFiles", commitJavaFiles) + project.setProperty("commitAuthor", getCommitAuthor()) +} + + diff --git a/codequality/detekt.gradle b/codequality/detekt.gradle index b6f417e01b..196d02a2ba 100644 --- a/codequality/detekt.gradle +++ b/codequality/detekt.gradle @@ -1,53 +1,40 @@ -plugins { - id("io.gitlab.arturbosch.detekt") version "1.15.0" -} +//apply plugin: 'io.gitlab.arturbosch.detekt' def pmdConfigPath = rootProject.file("codequality").path -detekt{ - //将配置文件应用于detekt的默认配置文件之上 - buildUponDefaultConfig = true - source = files( - "src/main/kotlin", - "src/main/java", - "src/jinlvvan/java", - "src/jinlvvan/kotlin", - "src/driverm1/java", - "src/driverm1/kotlin" - ) - //规则集 - config.setFrom("${pmdConfigPath}/detekt.yml") - //指定基准文件。在detekt的后续运行中,所有发现都存储在此文件中 - baseline = files("${pmdConfigPath}/baseline.xml") - //指定格式化报告中文件路径的基本路径 - basePath = projectDir.path +//detekt { +// //将配置文件应用于detekt的默认配置文件之上 +// buildUponDefaultConfig = true +// source = files( +// "src/main/kotlin", +// "src/main/java", +// "src/jinlvvan/java", +// "src/jinlvvan/kotlin", +// "src/driverm1/java", +// "src/driverm1/kotlin" +// ) +// //规则集 +// config.setFrom("${pmdConfigPath}/detekt.yml") +// //指定基准文件。在detekt的后续运行中,所有发现都存储在此文件中 +// baseline = files("${pmdConfigPath}/baseline.xml") +// //指定格式化报告中文件路径的基本路径 +// basePath = projectDir.path +// +// // Android: Don't create tasks for the specified build types (e.g. "release") +//// ignoredBuildTypes = ["release"] +// // Android: Don't create tasks for the specified build flavor (e.g. "production") +//// ignoredFlavors = ["production"] +// // Android: Don't create tasks for the specified build variants (e.g. "productionRelease") +//// ignoredVariants = ["productionRelease"] +//} - // Android: Don't create tasks for the specified build types (e.g. "release") -// ignoredBuildTypes = ["release"] - // Android: Don't create tasks for the specified build flavor (e.g. "production") -// ignoredFlavors = ["production"] - // Android: Don't create tasks for the specified build variants (e.g. "productionRelease") -// ignoredVariants = ["productionRelease"] -} - -dependencies { - detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.21.0" -} - -tasks.detekt.jvmTarget = "1.8" - -tasks.named("detekt").configure { - reports { - // Enable/Disable HTML report (default: true) - def destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") - html.required.set(true) - html.outputLocation.set(destination) - } -} - -project.afterEvaluate { - if (tasks.findByName("preBuild") != null) { - project.preBuild.dependsOn tasks.findByName("detekt") - println("project.preBuild.dependsOn tasks.findByName(\"detekt\")") - } -} \ No newline at end of file +//tasks.detekt.jvmTarget = "1.8" +// +//tasks.named("detekt").configure { +// reports { +// // Enable/Disable HTML report (default: true) +// def destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") +// html.required.set(true) +// html.outputLocation.set(destination) +// } +//} diff --git a/config.gradle b/config.gradle index d5d4d49b8c..01d3248be9 100644 --- a/config.gradle +++ b/config.gradle @@ -2,6 +2,12 @@ apply from: rootProject.file('gradle/ext.gradle') ext { time = "" kotlin_version = "1.6.21" + + //插件工具存放目录 + codequality = new File(projectDir, 'codequality') + //静态代码检查开关 + isCodeInspectEnable = true + dependencies = [ // androidx androidxappcompat : "androidx.appcompat:appcompat:1.3.1", From 3dd35d082d9bf462e78cde46a84d70b9b9ea3d8f Mon Sep 17 00:00:00 2001 From: zhongchao Date: Tue, 26 Sep 2023 18:41:45 +0800 Subject: [PATCH 08/24] [6.1.0] fix bug of detekt --- codequality/detekt.gradle | 67 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/codequality/detekt.gradle b/codequality/detekt.gradle index 196d02a2ba..dffe686e12 100644 --- a/codequality/detekt.gradle +++ b/codequality/detekt.gradle @@ -1,40 +1,39 @@ -//apply plugin: 'io.gitlab.arturbosch.detekt' +apply plugin: 'io.gitlab.arturbosch.detekt' def pmdConfigPath = rootProject.file("codequality").path -//detekt { -// //将配置文件应用于detekt的默认配置文件之上 -// buildUponDefaultConfig = true -// source = files( -// "src/main/kotlin", -// "src/main/java", -// "src/jinlvvan/java", -// "src/jinlvvan/kotlin", -// "src/driverm1/java", -// "src/driverm1/kotlin" -// ) -// //规则集 -// config.setFrom("${pmdConfigPath}/detekt.yml") -// //指定基准文件。在detekt的后续运行中,所有发现都存储在此文件中 -// baseline = files("${pmdConfigPath}/baseline.xml") -// //指定格式化报告中文件路径的基本路径 -// basePath = projectDir.path -// -// // Android: Don't create tasks for the specified build types (e.g. "release") -//// ignoredBuildTypes = ["release"] -// // Android: Don't create tasks for the specified build flavor (e.g. "production") -//// ignoredFlavors = ["production"] -// // Android: Don't create tasks for the specified build variants (e.g. "productionRelease") -//// ignoredVariants = ["productionRelease"] -//} +detekt { + toolVersion = "1.15.0" + input = objects.fileCollection().from( + "src/main/kotlin", + "src/main/java", + "src/jinlvvan/java", + "src/jinlvvan/kotlin", + "src/driverm1/java", + "src/driverm1/kotlin" + ) + //规则集 + config.setFrom("${pmdConfigPath}/detekt.yml") + //指定基准文件。在detekt的后续运行中,所有发现都存储在此文件中 + baseline = file("${pmdConfigPath}/baseline.xml") + //将配置文件应用于detekt的默认配置文件之上 + buildUponDefaultConfig = true -//tasks.detekt.jvmTarget = "1.8" -// -//tasks.named("detekt").configure { -// reports { -// // Enable/Disable HTML report (default: true) -// def destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") + // Android: Don't create tasks for the specified build types (e.g. "release") +// ignoredBuildTypes = ["release"] + // Android: Don't create tasks for the specified build flavor (e.g. "production") +// ignoredFlavors = ["production"] + // Android: Don't create tasks for the specified build variants (e.g. "productionRelease") +// ignoredVariants = ["productionRelease"] +} + +tasks.detekt.jvmTarget = "1.8" + +tasks.named("detekt").configure { + reports { + // Enable/Disable HTML report (default: true) + def destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") // html.required.set(true) // html.outputLocation.set(destination) -// } -//} + } +} From 722607fba42a074e3b61b6a0c7bcb23d03aa5e25 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Wed, 27 Sep 2023 14:21:40 +0800 Subject: [PATCH 09/24] [3.4.0-map-sdk] code style --- .../passenger/ui/selectline/SelectLineView.kt | 6 +- .../taxi/passenger/ui/video/InfoVideoView.kt | 8 +- .../mogo/launcher/lancet/MainBlockCheck.kt | 1 - build.gradle | 12 +- codequality/code_inspect.gradle | 2 +- codequality/custom-pmd-ruleset.xml | 6 +- codequality/detekt.gradle | 24 +- codequality/detekt.yml | 574 +++++++++--------- .../media/video/NoticeSimpleVideoPlayer.kt | 2 + .../com/mogo/commons/koom/KoomInitTask.kt | 2 + gradle/wrapper/gradle-wrapper.properties | 2 +- 11 files changed, 318 insertions(+), 321 deletions(-) diff --git a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/selectline/SelectLineView.kt b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/selectline/SelectLineView.kt index 5620c12797..c67afd2964 100644 --- a/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/selectline/SelectLineView.kt +++ b/OCH/charter/passenger/src/main/java/com/mogo/och/charter/passenger/ui/selectline/SelectLineView.kt @@ -46,8 +46,6 @@ import org.greenrobot.eventbus.EventBus */ class SelectLineView : ConstraintLayout, SelectLineViewModel.SelectLineViewCallback { - private val TAG = "OrderInfoView" - constructor(context: Context) : super(context) constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) @@ -101,7 +99,7 @@ class SelectLineView : ConstraintLayout, SelectLineViewModel.SelectLineViewCallb rlv_line_list.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) rlv_line_list.addItemDecoration( - com.mogo.och.charter.passenger.ui.selectline.layoutmanage.BottomDecoration( + BottomDecoration( AutoSizeUtils.dp2px(context, 60f) ) ) @@ -110,7 +108,7 @@ class SelectLineView : ConstraintLayout, SelectLineViewModel.SelectLineViewCallb rv_site_list.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) rv_site_list.addItemDecoration( - com.mogo.och.charter.passenger.ui.selectline.layoutmanage.BottomDecoration( + BottomDecoration( AutoSizeUtils.dp2px(context, 90f) ) ) diff --git a/OCH/taxi/passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt b/OCH/taxi/passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt index d8212bac16..e521cfbc50 100644 --- a/OCH/taxi/passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt +++ b/OCH/taxi/passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt @@ -61,7 +61,7 @@ internal class InfoVideoView @JvmOverloads constructor( "蘑菇车联之红旗车队" )) add( - com.mogo.och.taxi.passenger.bean.TaxiPassengerVideoPlay( + TaxiPassengerVideoPlay( "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v", "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png", "蘑菇车联牵手成都大运会" @@ -79,7 +79,7 @@ internal class InfoVideoView @JvmOverloads constructor( fun exitFullScreenMode(resetVideoPlayer: Boolean) { val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager - val (centerItemPosition: Int, player) = getPlayer(carouselLayoutManager) + val (_: Int, player) = getPlayer(carouselLayoutManager) player?.let { it.exitFullScreenMode() it.onVideoPause() @@ -100,7 +100,7 @@ internal class InfoVideoView @JvmOverloads constructor( return } val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager - val (centerItemPosition: Int, player) = getPlayer(carouselLayoutManager) + val (_: Int, player) = getPlayer(carouselLayoutManager) when (visibility) { View.VISIBLE -> { player?.let { @@ -218,7 +218,7 @@ internal class InfoVideoView @JvmOverloads constructor( override fun onWindowFocusChanged(hasWindowFocus: Boolean) { super.onWindowFocusChanged(hasWindowFocus) val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager - val (centerItemPosition: Int, player) = getPlayer(carouselLayoutManager) + val (_: Int, player) = getPlayer(carouselLayoutManager) player?.let { if(it.isInPlayingState&&!it.isIfCurrentIsFullscreen&&!hasWindowFocus){ player.onVideoPause() diff --git a/app/src/main/java/com/mogo/launcher/lancet/MainBlockCheck.kt b/app/src/main/java/com/mogo/launcher/lancet/MainBlockCheck.kt index 8fd39e4280..14b4401f1a 100644 --- a/app/src/main/java/com/mogo/launcher/lancet/MainBlockCheck.kt +++ b/app/src/main/java/com/mogo/launcher/lancet/MainBlockCheck.kt @@ -19,7 +19,6 @@ import com.mogo.eagle.core.block.runtime.config.recorder.* import com.mogo.eagle.core.block.runtime.utils.TimeUtils.Companion.now import com.mogo.eagle.core.function.call.devatools.* import com.mogo.eagle.core.utilcode.util.* -import kotlinx.coroutines.* import kotlinx.coroutines.Runnable import java.lang.ref.WeakReference import java.util.LinkedList diff --git a/build.gradle b/build.gradle index 190f5f0714..40ba76905b 100644 --- a/build.gradle +++ b/build.gradle @@ -74,14 +74,14 @@ allprojects { } if (isCodeInspectEnable ) { - def basePath = new File(codequality, 'code_inspect_increment.gradle').path - apply from: "$basePath" - def pmdPath = new File(codequality, 'pmd.gradle').path - apply from: "$pmdPath" +// def basePath = new File(codequality, 'code_inspect_increment.gradle').path +// apply from: "$basePath" +// def pmdPath = new File(codequality, 'pmd.gradle').path +// apply from: "$pmdPath" def detektPath = new File(codequality, 'detekt.gradle').path apply from: "$detektPath" - def codeInspectPath = new File(codequality, 'code_inspect.gradle').path - apply from: "$codeInspectPath" +// def codeInspectPath = new File(codequality, 'code_inspect.gradle').path +// apply from: "$codeInspectPath" } } diff --git a/codequality/code_inspect.gradle b/codequality/code_inspect.gradle index ab96a4c056..2853f3d1f0 100644 --- a/codequality/code_inspect.gradle +++ b/codequality/code_inspect.gradle @@ -1,6 +1,6 @@ task runCodeInspect { group = "codeInspect" - description = "静态代码检查,统一触发pmd detekt lint任务" + description = "静态代码检查,统一触发pmd detekt任务" } project.afterEvaluate { diff --git a/codequality/custom-pmd-ruleset.xml b/codequality/custom-pmd-ruleset.xml index 835269cdce..884a4702e7 100644 --- a/codequality/custom-pmd-ruleset.xml +++ b/codequality/custom-pmd-ruleset.xml @@ -25,8 +25,6 @@ - - @@ -44,9 +42,7 @@ - - - + diff --git a/codequality/detekt.gradle b/codequality/detekt.gradle index dffe686e12..1129174a38 100644 --- a/codequality/detekt.gradle +++ b/codequality/detekt.gradle @@ -4,20 +4,18 @@ def pmdConfigPath = rootProject.file("codequality").path detekt { toolVersion = "1.15.0" - input = objects.fileCollection().from( - "src/main/kotlin", + input = files( "src/main/java", "src/jinlvvan/java", - "src/jinlvvan/kotlin", - "src/driverm1/java", - "src/driverm1/kotlin" + "src/driverm1/java" ) + //将配置文件应用于detekt的默认配置文件之上 + buildUponDefaultConfig = true //规则集 config.setFrom("${pmdConfigPath}/detekt.yml") //指定基准文件。在detekt的后续运行中,所有发现都存储在此文件中 - baseline = file("${pmdConfigPath}/baseline.xml") - //将配置文件应用于detekt的默认配置文件之上 - buildUponDefaultConfig = true +// baseline = file("${pmdConfigPath}/baseline.xml") + // Android: Don't create tasks for the specified build types (e.g. "release") // ignoredBuildTypes = ["release"] @@ -27,13 +25,15 @@ detekt { // ignoredVariants = ["productionRelease"] } -tasks.detekt.jvmTarget = "1.8" +tasks.detekt.jvmTarget = "1.11" tasks.named("detekt").configure { reports { // Enable/Disable HTML report (default: true) - def destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") -// html.required.set(true) -// html.outputLocation.set(destination) + html { + enabled = true + // Path where HTML report will be stored (default: `build/reports/detekt/detekt.html`) + destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") + } } } diff --git a/codequality/detekt.yml b/codequality/detekt.yml index 73af812f49..492f87f811 100644 --- a/codequality/detekt.yml +++ b/codequality/detekt.yml @@ -4,9 +4,9 @@ build: config: validation: true warningsAsErrors: false - checkExhaustiveness: false +# checkExhaustiveness: false # when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]' - excludes: '' + excludes: 'custom-checks.*' processors: active: true @@ -49,24 +49,24 @@ comments: AbsentOrWrongFileLicense: #报告每个没有所需许可证标头的Kotlin源文件 active: false licenseTemplateFile: 'license.template' - licenseTemplateIsRegex: false +# licenseTemplateIsRegex: false CommentOverPrivateFunction: #报告private函数的注释和文档 active: false CommentOverPrivateProperty: #报告私有属性的注释和文档 active: false - DeprecatedBlockTag: #报告注释中使用@deprecated块标记,可以使用@ReplaceWith annotations - active: false +# DeprecatedBlockTag: #报告注释中使用@deprecated块标记,可以使用@ReplaceWith annotations +# active: false EndOfSentenceFormat: #验证KDoc注释的第一句话的结尾 active: false endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' - KDocReferencesNonPublicProperty: #报告任何引用类的非公共属性的KDoc注释 - active: false +# KDocReferencesNonPublicProperty: #报告任何引用类的非公共属性的KDoc注释 +# active: false excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] - OutdatedDocumentation: #报告任何具有与声明签名不匹配的KDoc的类、函数或构造函数 - active: false - matchTypeParameters: true - matchDeclarationsOrder: true - allowParamOnConstructorProperties: false +# OutdatedDocumentation: #报告任何具有与声明签名不匹配的KDoc的类、函数或构造函数 +# active: false +# matchTypeParameters: true +# matchDeclarationsOrder: true +# allowParamOnConstructorProperties: false UndocumentedPublicClass: #报告没有所需文档的公共类、对象和接口 active: false excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] @@ -74,101 +74,101 @@ comments: searchInInnerClass: true searchInInnerObject: true searchInInnerInterface: true - searchInProtectedClass: false +# searchInProtectedClass: false UndocumentedPublicFunction: #报告任何没有所需文档的公共方法 active: false excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] - searchProtectedFunction: false +# searchProtectedFunction: false UndocumentedPublicProperty: #报告任何没有所需文档的公共字段 active: false excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] - searchProtectedProperty: false +# searchProtectedProperty: false complexity: active: true - CognitiveComplexMethod: #报告复杂方法 - active: false - allowedComplexity: 15 +# CognitiveComplexMethod: #报告复杂方法 +# active: false +# allowedComplexity: 15 ComplexCondition: #报告复杂条件 active: false - allowedConditions: 4 +# allowedConditions: 4 ComplexInterface: #包含太多函数和/或属性的复杂接口表明该接口一次处理太多事情。接口应该遵循单一责任原则,以鼓励该接口的实现不要同时处理太多事情 active: false - allowedDefinitions: 10 +# allowedDefinitions: 10 includeStaticDeclarations: false includePrivateDeclarations: false - ignoreOverloaded: false +# ignoreOverloaded: false #该规则使用McCabe的循环复杂性(MCC)度量来测量函数源代码中线性独立路径的数量{https://www.ndepend.com/docs/code-metrics#CC} - CyclomaticComplexMethod: #复杂的方法很难理解和阅读。复杂方法的副作用可能并不明显。更喜欢把复杂的方法分解成更小的方法,这样更容易理解。较小的方法也可以命名得更清晰,从而提高代码的可读性。 - active: true - allowedComplexity: 14 - ignoreSingleWhenExpression: false - ignoreSimpleWhenEntries: false - ignoreNestingFunctions: false - ignoreLocalFunctions: false - nestingFunctions: - - 'also' - - 'apply' - - 'forEach' - - 'isNotNull' - - 'ifNull' - - 'let' - - 'run' - - 'use' - - 'with' +# CyclomaticComplexMethod: #复杂的方法很难理解和阅读。复杂方法的副作用可能并不明显。更喜欢把复杂的方法分解成更小的方法,这样更容易理解。较小的方法也可以命名得更清晰,从而提高代码的可读性。 +# active: true +# allowedComplexity: 14 +# ignoreSingleWhenExpression: false +# ignoreSimpleWhenEntries: false +# ignoreNestingFunctions: false +# ignoreLocalFunctions: false +# nestingFunctions: +# - 'also' +# - 'apply' +# - 'forEach' +# - 'isNotNull' +# - 'ifNull' +# - 'let' +# - 'run' +# - 'use' +# - 'with' LabeledExpression: #报告已标记的表达式 active: false ignoredLabels: [] LargeClass: #报告大型类 active: true - allowedLines: 600 +# allowedLines: 600 LongMethod: #报告大方法 active: true - allowedLines: 60 +# allowedLines: 60 LongParameterList: #报告参数超过特定阈值的函数和构造函数。 active: true - allowedFunctionParameters: 6 - allowedConstructorParameters: 15 +# allowedFunctionParameters: 6 +# allowedConstructorParameters: 15 ignoreDefaultParameters: false ignoreDataClasses: true - ignoreAnnotatedParameter: [] +# ignoreAnnotatedParameter: [] MethodOverloading: #报告经常重载的方法 active: false - allowedOverloads: 6 +# allowedOverloads: 6 NamedArguments: #报告参数超过某个阈值且全部未命名的函数调用。参数过多的调用更难理解,因此命名参数会有所帮助。 active: false - allowedArguments: 3 - ignoreArgumentsMatchingNames: false +# allowedArguments: 3 +# ignoreArgumentsMatchingNames: false NestedBlockDepth: #报告函数中嵌套深度过大 active: true - allowedDepth: 4 - NestedScopeFunctions: #避免嵌套作用域函数 - active: false - allowedDepth: 1 - functions: - - 'kotlin.apply' - - 'kotlin.run' - - 'kotlin.with' - - 'kotlin.let' - - 'kotlin.also' +# allowedDepth: 4 +# NestedScopeFunctions: #避免嵌套作用域函数 +# active: false +# allowedDepth: 1 +# functions: +# - 'kotlin.apply' +# - 'kotlin.run' +# - 'kotlin.with' +# - 'kotlin.let' +# - 'kotlin.also' ReplaceSafeCallChainWithRun: #不可为null的类型上的安全调用链是冗余的,可以通过将冗余的安全调用封装在run{}块中来删除 {xxx?.run} active: false StringLiteralDuplication: #规则检测并报告重复的字符串文字 active: false excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] - allowedDuplications: 2 +# allowedDuplications: 2 ignoreAnnotation: true - allowedWithLengthLessThan: 5 +# allowedWithLengthLessThan: 5 ignoreStringsRegex: '$^' TooManyFunctions: #此规则报告包含过多函数的文件、类、接口、对象和枚举。每个元素可以配置有不同的阈值。 active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] - allowedFunctionsPerFile: 11 - allowedFunctionsPerClass: 11 - allowedFunctionsPerInterface: 11 - allowedFunctionsPerObject: 11 - allowedFunctionsPerEnum: 11 +# allowedFunctionsPerFile: 11 +# allowedFunctionsPerClass: 11 +# allowedFunctionsPerInterface: 11 +# allowedFunctionsPerObject: 11 +# allowedFunctionsPerEnum: 11 ignoreDeprecated: false ignorePrivate: false ignoreOverridden: false @@ -178,20 +178,20 @@ coroutines: active: true GlobalCoroutineUsage: active: false - InjectDispatcher: #始终使用依赖项注入来注入调度器,以便于测试 - active: true - dispatcherNames: - - 'IO' - - 'Default' - - 'Unconfined' +# InjectDispatcher: #始终使用依赖项注入来注入调度器,以便于测试 +# active: true +# dispatcherNames: +# - 'IO' +# - 'Default' +# - 'Unconfined' RedundantSuspendModifier: #suspend修饰符只能在需要的地方使用,否则该函数只能从其他挂起函数中使用。这不必要地限制了函数的使用,应该通过删除不需要的suspend修饰符来避免 active: true - SleepInsteadOfDelay: #报告Thread.sleep在挂起函数和协同程序块中的使用情况。由于协程的轻量级性质,一个线程可以同时包含多个协程,因此如果一个协程调用thread.sleep,它可能会停止执行不相关的协程,并导致不可预测的行为。 - active: true - SuspendFunSwallowedCancellation: #不应在runCatching的lambda块内部调用suspend函数 - active: false - SuspendFunWithCoroutineScopeReceiver: #将CoroutineScope用作接收器的挂起函数不应标记为挂起。 - active: false +# SleepInsteadOfDelay: #报告Thread.sleep在挂起函数和协同程序块中的使用情况。由于协程的轻量级性质,一个线程可以同时包含多个协程,因此如果一个协程调用thread.sleep,它可能会停止执行不相关的协程,并导致不可预测的行为。 +# active: true +# SuspendFunSwallowedCancellation: #不应在runCatching的lambda块内部调用suspend函数 +# active: false +# SuspendFunWithCoroutineScopeReceiver: #将CoroutineScope用作接收器的挂起函数不应标记为挂起。 +# active: false SuspendFunWithFlowReturnType: #从kotlin.coroutines.Flow返回Flow的函数不应标记为挂起,简单地调用一个返回Flow的函数的行为不应该有任何副作用。只有当针对返回的Flow开始收集时,才应该实际完成工作。 active: true @@ -220,8 +220,8 @@ empty-blocks: active: true EmptyInitBlock: #报告为空的init块。空代码块没有任何作用,应该删除 active: true - EmptyKotlinFile: #报告为空的kotlin文件。空代码块没有任何作用,应该删除 - active: true +# EmptyKotlinFile: #报告为空的kotlin文件。空代码块没有任何作用,应该删除 +# active: true EmptySecondaryConstructor: #报告为空的辅助构造函数。空代码块没有任何作用,应该删除 active: true EmptyTryBlock: #报告为空的try块。空代码块没有任何作用,应该删除 @@ -245,8 +245,8 @@ exceptions: excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] NotImplementedDeclaration: #此规则报告引发的所有NotImplementedError类型的异常。它还报告所有TODO(..)函数。这表明功能仍在开发中,无法正常工作。这两种声明都只能作为临时声明,不应放入生产环境中 active: false - ObjectExtendsThrowable: #避免抛出单例Throwable - active: false +# ObjectExtendsThrowable: #避免抛出单例Throwable +# active: false PrintStackTrace: #打印堆栈 active: true RethrowCaughtException: #重新抛出异常 @@ -304,9 +304,9 @@ exceptions: naming: active: true - BooleanPropertyNaming: - active: false - allowedPattern: '^(is|has|are)' +# BooleanPropertyNaming: +# active: false +# allowedPattern: '^(is|has|are)' ClassNaming: active: true classPattern: '[A-Z][a-zA-Z0-9]*' @@ -321,12 +321,12 @@ naming: ForbiddenClassName: active: false forbiddenName: [] - FunctionNameMaxLength: - active: false - maximumFunctionNameLength: 30 - FunctionNameMinLength: - active: false - minimumFunctionNameLength: 3 +# FunctionNameMaxLength: +# active: false +# maximumFunctionNameLength: 30 +# FunctionNameMinLength: +# active: false +# minimumFunctionNameLength: 3 FunctionNaming: active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] @@ -339,29 +339,29 @@ naming: InvalidPackageDeclaration: active: true rootPackage: '' - requireRootInDeclaration: false - LambdaParameterNaming: - active: false - parameterPattern: '[a-z][A-Za-z0-9]*|_' +# requireRootInDeclaration: false +# LambdaParameterNaming: +# active: false +# parameterPattern: '[a-z][A-Za-z0-9]*|_' MatchingDeclarationName: active: true mustBeFirst: true - multiplatformTargets: - - 'ios' - - 'android' - - 'js' - - 'jvm' - - 'native' - - 'iosArm64' - - 'iosX64' - - 'macosX64' - - 'mingwX64' - - 'linuxX64' +# multiplatformTargets: +# - 'ios' +# - 'android' +# - 'js' +# - 'jvm' +# - 'native' +# - 'iosArm64' +# - 'iosX64' +# - 'macosX64' +# - 'mingwX64' +# - 'linuxX64' MemberNameEqualsClassName: active: true ignoreOverridden: true - NoNameShadowing: - active: true +# NoNameShadowing: +# active: true NonBooleanPropertyPrefixedWithIs: active: false ObjectPropertyNaming: @@ -393,58 +393,58 @@ performance: active: true ArrayPrimitive: #使用Array<Primitive>会导致隐含拳击和性能打击。更喜欢使用Kotlin专用的数组实例 active: true - CouldBeSequence: #由于每个调用都会创建一个新的列表,因此长链的收集操作将带来性能损失。请考虑使用序列 - active: false - allowedOperations: 2 +# CouldBeSequence: #由于每个调用都会创建一个新的列表,因此长链的收集操作将带来性能损失。请考虑使用序列 +# active: false +# allowedOperations: 2 ForEachOnRange: #在一个范围内使用forEach可能会产生巨大的性能成本。因此,在大多数情况下,应该使用简单的for循环 (for example: {(1..10).forEach}) active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] SpreadOperator: #在大多数情况下,使用排列运算符会导致在调用方法之前创建数组的完整副本。这会带来非常高的性能损失 active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] - UnnecessaryPartOfBinaryExpression: #仅在表达式仅使用以下运算符之一||或&&的情况下验证二进制表达式 - active: false +# UnnecessaryPartOfBinaryExpression: #仅在表达式仅使用以下运算符之一||或&&的情况下验证二进制表达式 +# active: false UnnecessaryTemporaryInstantiation: #将基元类型转换为字符串时,请避免使用临时对象。与直接使用基元类型相比,这会降低性能。若要解决此问题,请删除包装类型 active: true #潜在错误规则集提供了检测潜在错误的规则。 potential-bugs: active: true - AvoidReferentialEquality: #检查平等 - active: true - forbiddenTypePatterns: - - 'kotlin.String' - CastNullableToNonNullableType: #可空强转null - active: false - ignorePlatformTypes: true - CastToNullableType: #将不安全的强制转换报告为可为null的类型。作为字符串?未填充,可能被误用为安全类型转换(如?字符串) - active: false - CharArrayToStringCall: - active: false +# AvoidReferentialEquality: #检查平等 +# active: true +# forbiddenTypePatterns: +# - 'kotlin.String' +# CastNullableToNonNullableType: #可空强转null +# active: false +# ignorePlatformTypes: true +# CastToNullableType: #将不安全的强制转换报告为可为null的类型。作为字符串?未填充,可能被误用为安全类型转换(如?字符串) +# active: false +# CharArrayToStringCall: +# active: false Deprecation: active: false - DontDowncastCollectionTypes: #检查集合向下类型转换,建议方法转换({list as MutableList} convert : {list.toMutableList()}) - active: false - DoubleMutabilityForCollection: #MutableState可变var,不可变建议val - active: true - mutableTypes: - - 'kotlin.collections.MutableList' - - 'kotlin.collections.MutableMap' - - 'kotlin.collections.MutableSet' - - 'java.util.ArrayList' - - 'java.util.LinkedHashSet' - - 'java.util.HashSet' - - 'java.util.LinkedHashMap' - - 'java.util.HashMap' - ElseCaseInsteadOfExhaustiveWhen: #当表达式包含else大小写时,即使它们有一组详尽的大小写,该规则也会报告 - active: false - ignoredSubjectTypes: [] +# DontDowncastCollectionTypes: #检查集合向下类型转换,建议方法转换({list as MutableList} convert : {list.toMutableList()}) +# active: false +# DoubleMutabilityForCollection: #MutableState可变var,不可变建议val +# active: true +# mutableTypes: +# - 'kotlin.collections.MutableList' +# - 'kotlin.collections.MutableMap' +# - 'kotlin.collections.MutableSet' +# - 'java.util.ArrayList' +# - 'java.util.LinkedHashSet' +# - 'java.util.HashSet' +# - 'java.util.LinkedHashMap' +# - 'java.util.HashMap' +# ElseCaseInsteadOfExhaustiveWhen: #当表达式包含else大小写时,即使它们有一组详尽的大小写,该规则也会报告 +# active: false +# ignoredSubjectTypes: [] EqualsAlwaysReturnsTrueOrFalse: #报告始终返回true或false的equals()方法。 active: true EqualsWithHashCodeExist: #当一个类重写equals()方法时,它也应该重写hashCode()方法 active: true - ExitOutsideMain: #报告主函数之外使用System.exit()、Runtime.exit()、Runtime.holt()和Kotlin的exitProcess()时的使用情况 - active: false +# ExitOutsideMain: #报告主函数之外使用System.exit()、Runtime.exit()、Runtime.holt()和Kotlin的exitProcess()时的使用情况 +# active: false ExplicitGarbageCollectionCall: #报告所有显式触发垃圾回收器的调用。代码应该独立于垃圾收集器工作,并且不应该要求在某些时间点触发GC。 active: true HasPlatformType: #必须在公共API中显式声明平台类型,以防止出现意外错误 @@ -452,21 +452,21 @@ potential-bugs: #此规则对使用@CheckReturnValue或@CheckResult注释的函数返回值但未以任何方式使用该值的实例发出警告Kotlin编译器通常不会对这种情况发出警告,所以这就是该规则背后的基本原理。 IgnoredReturnValue: - active: true - restrictToConfig: true + active: false +# restrictToConfig: true returnValueAnnotations: - 'CheckResult' - '*.CheckResult' - 'CheckReturnValue' - '*.CheckReturnValue' - ignoreReturnValueAnnotations: - - 'CanIgnoreReturnValue' - - '*.CanIgnoreReturnValue' - returnValueTypes: - - 'kotlin.sequences.Sequence' - - 'kotlinx.coroutines.flow.*Flow' - - 'java.util.stream.*Stream' - ignoreFunctionCall: [] +# ignoreReturnValueAnnotations: +# - 'CanIgnoreReturnValue' +# - '*.CanIgnoreReturnValue' +# returnValueTypes: +# - 'kotlin.sequences.Sequence' +# - 'kotlinx.coroutines.flow.*Flow' +# - 'java.util.stream.*Stream' +# ignoreFunctionCall: [] ImplicitDefaultLocale: #格式化字符串或执行大小写转换时,更喜欢显式传递[java.util.Locale],而不是使用隐式默认值 active: false ImplicitUnitReturnType: #使用表达式语句的函数具有隐式返回类型 @@ -484,25 +484,25 @@ potential-bugs: ignoreOnClassesPattern: '' MapGetWithNotNullAssertionOperator: #使用非null断言运算符报告对map访问方法map[]或map.get()的调用!!。这可能会导致NullPointerException active: true - MissingPackageDeclaration: #当缺少包声明时报告 - active: false - excludes: ['**/*.kts'] - NullCheckOnMutableProperty: #报告对可变属性的null检查,因为这些属性的值可以在执行if语句后更改,从而使null检查无效 - active: false +# MissingPackageDeclaration: #当缺少包声明时报告 +# active: false +# excludes: ['**/*.kts'] +# NullCheckOnMutableProperty: #报告对可变属性的null检查,因为这些属性的值可以在执行if语句后更改,从而使null检查无效 +# active: false NullableToStringCall: #使用可能返回字符串“null”的可为null的接收器报告toString()调用 active: false - PropertyUsedBeforeDeclaration: #报告在声明之前使用的属性 - active: false +# PropertyUsedBeforeDeclaration: #报告在声明之前使用的属性 +# active: false UnconditionalJumpStatementInLoop: #报告包含跳转语句的循环,这些语句在任何条件下都会跳转 active: false - UnnecessaryNotNullCheck: #使用requireNotNull或checkNotNull报告用户可以删除的不必要的非null检查。 - active: false +# UnnecessaryNotNullCheck: #使用requireNotNull或checkNotNull报告用户可以删除的不必要的非null检查。 +# active: false UnnecessaryNotNullOperator: #报告用户可以删除的不必要的非null运算符用法(!!) active: true UnnecessarySafeCall: #报告用户可以删除的不必要的非null运算符用法(?) active: true - UnreachableCatchBlock: #报告无法访问的捕获块。如果在上面的块中已经捕获到异常,则捕获块可能无法访问(Exception or Throwable)catch顺序 - active: true +# UnreachableCatchBlock: #报告无法访问的捕获块。如果在上面的块中已经捕获到异常,则捕获块可能无法访问(Exception or Throwable)catch顺序 +# active: true UnreachableCode: #报告无法访问的代码。代码可能无法访问,因为它位于return、throw、continue或break表达式后面 active: true UnsafeCallOnNullableType: #报告对可为null的类型的不安全调用 @@ -510,8 +510,8 @@ potential-bugs: excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**'] UnsafeCast: #报告不安全的强制转换 active: true - UnusedUnaryOperator: #检测未使用的一元运算符 - active: true +# UnusedUnaryOperator: #检测未使用的一元运算符 +# active: true UselessPostfixExpression: #报告未使用因而不必要的后缀表达式(++,--) active: true WrongEqualsTypeParameter: #报告接受错误类型参数的equals()方法 @@ -520,25 +520,25 @@ potential-bugs: #{link https://detekt.dev/docs/rules/style#explicititlambdaparameter} style: active: true - AbstractClassCanBeConcreteClass: - active: true - AbstractClassCanBeInterface: - active: true - AlsoCouldBeApply: - active: false - BracesOnIfStatements: - active: false - singleLine: 'never' - multiLine: 'always' - BracesOnWhenStatements: - active: false - singleLine: 'necessary' - multiLine: 'consistent' - CanBeNonNullable: - active: false - CascadingCallWrapping: - active: false - includeElvis: true +# AbstractClassCanBeConcreteClass: +# active: true +# AbstractClassCanBeInterface: +# active: true +# AlsoCouldBeApply: +# active: false +# BracesOnIfStatements: +# active: false +# singleLine: 'never' +# multiLine: 'always' +# BracesOnWhenStatements: +# active: false +# singleLine: 'necessary' +# multiLine: 'consistent' +# CanBeNonNullable: +# active: false +# CascadingCallWrapping: +# active: false +# includeElvis: true ClassOrdering: active: false CollapsibleIfStatements: @@ -547,22 +547,22 @@ style: active: false conversionFunctionPrefix: - 'to' - allowOperators: false +# allowOperators: false DataClassShouldBeImmutable: active: false - DestructuringDeclarationWithTooManyEntries: - active: false - maxDestructuringEntries: 3 - DoubleNegativeLambda: - active: false - negativeFunctions: - - reason: 'Use `takeIf` instead.' - value: 'takeUnless' - - reason: 'Use `all` instead.' - value: 'none' - negativeFunctionNameParts: - - 'not' - - 'non' +# DestructuringDeclarationWithTooManyEntries: +# active: false +# maxDestructuringEntries: 3 +# DoubleNegativeLambda: +# active: false +# negativeFunctions: +# - reason: 'Use `takeIf` instead.' +# value: 'takeUnless' +# - reason: 'Use `all` instead.' +# value: 'none' +# negativeFunctionNameParts: +# - 'not' +# - 'non' EqualsNullCall: active: true EqualsOnSignatureLine: @@ -574,32 +574,32 @@ style: ExpressionBodySyntax: active: false includeLineWrapping: false - ForbiddenAnnotation: - active: false - annotations: - - reason: 'it is a java annotation. Use `Suppress` instead.' - value: 'java.lang.SuppressWarnings' - - reason: 'it is a java annotation. Use `kotlin.Deprecated` instead.' - value: 'java.lang.Deprecated' - - reason: 'it is a java annotation. Use `kotlin.annotation.MustBeDocumented` instead.' - value: 'java.lang.annotation.Documented' - - reason: 'it is a java annotation. Use `kotlin.annotation.Target` instead.' - value: 'java.lang.annotation.Target' - - reason: 'it is a java annotation. Use `kotlin.annotation.Retention` instead.' - value: 'java.lang.annotation.Retention' - - reason: 'it is a java annotation. Use `kotlin.annotation.Repeatable` instead.' - value: 'java.lang.annotation.Repeatable' - - reason: 'Kotlin does not support @Inherited annotation, see https://youtrack.jetbrains.com/issue/KT-22265' - value: 'java.lang.annotation.Inherited' +# ForbiddenAnnotation: +# active: false +# annotations: +# - reason: 'it is a java annotation. Use `Suppress` instead.' +# value: 'java.lang.SuppressWarnings' +# - reason: 'it is a java annotation. Use `kotlin.Deprecated` instead.' +# value: 'java.lang.Deprecated' +# - reason: 'it is a java annotation. Use `kotlin.annotation.MustBeDocumented` instead.' +# value: 'java.lang.annotation.Documented' +# - reason: 'it is a java annotation. Use `kotlin.annotation.Target` instead.' +# value: 'java.lang.annotation.Target' +# - reason: 'it is a java annotation. Use `kotlin.annotation.Retention` instead.' +# value: 'java.lang.annotation.Retention' +# - reason: 'it is a java annotation. Use `kotlin.annotation.Repeatable` instead.' +# value: 'java.lang.annotation.Repeatable' +# - reason: 'Kotlin does not support @Inherited annotation, see https://youtrack.jetbrains.com/issue/KT-22265' +# value: 'java.lang.annotation.Inherited' ForbiddenComment: active: false - comments: - - reason: 'Forbidden FIXME todo marker in comment, please fix the problem.' - value: 'FIXME:' - - reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code.' - value: 'STOPSHIP:' - - reason: 'Forbidden TODO todo marker in comment, please do the changes.' - value: 'TODO:' +# comments: +# - reason: 'Forbidden FIXME todo marker in comment, please fix the problem.' +# value: 'FIXME:' +# - reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code.' +# value: 'STOPSHIP:' +# - reason: 'Forbidden TODO todo marker in comment, please do the changes.' +# value: 'TODO:' allowedPatterns: '' ForbiddenImport: active: false @@ -612,9 +612,9 @@ style: value: 'kotlin.io.print' - reason: 'println does not allow you to configure the output stream. Use a logger instead.' value: 'kotlin.io.println' - ForbiddenSuppress: - active: false - rules: [] +# ForbiddenSuppress: +# active: false +# rules: [] ForbiddenVoid: active: true ignoreOverridden: false @@ -622,7 +622,7 @@ style: FunctionOnlyReturningConstant: active: true ignoreOverridableFunction: true - ignoreActualFunction: true +# ignoreActualFunction: true excludedFunctions: [] LoopWithTooManyJumpStatements: active: true @@ -644,41 +644,41 @@ style: ignoreNamedArgument: true ignoreEnums: false ignoreRanges: false - ignoreExtensionFunctions: true +# ignoreExtensionFunctions: true MandatoryBracesLoops: active: false - MaxChainedCallsOnSameLine: - active: false - maxChainedCalls: 5 +# MaxChainedCallsOnSameLine: +# active: false +# maxChainedCalls: 5 MaxLineLength: active: true maxLineLength: 120 excludePackageStatements: true excludeImportStatements: true excludeCommentStatements: false - excludeRawStrings: true - MayBeConstant: - active: true +# excludeRawStrings: true +# MayBeConstant: +# active: true ModifierOrder: active: true - MultilineLambdaItParameter: - active: false - MultilineRawStringIndentation: - active: false - indentSize: 4 - trimmingMethods: - - 'trimIndent' - - 'trimMargin' +# MultilineLambdaItParameter: +# active: false +# MultilineRawStringIndentation: +# active: false +# indentSize: 4 +# trimmingMethods: +# - 'trimIndent' +# - 'trimMargin' NestedClassesVisibility: #嵌套类从父类继承其可见性,通常用于实现嵌套在其中的类的本地功能。这些嵌套类的可见性不能高于其父类 active: true NewLineAtEndOfFile: active: true NoTabs: active: false - NullableBooleanCheck: - active: false - ObjectLiteralToLambda: #除了实现单个方法之外什么都不做的匿名对象可以用作lambda。 - active: true +# NullableBooleanCheck: +# active: false +# ObjectLiteralToLambda: #除了实现单个方法之外什么都不做的匿名对象可以用作lambda。 +# active: true OptionalAbstractKeyword: active: true OptionalUnit: @@ -687,8 +687,8 @@ style: active: false ProtectedMemberInFinalClass: active: true - RangeUntilInsteadOfRangeTo: - active: false +# RangeUntilInsteadOfRangeTo: +# active: false RedundantExplicitType: active: false RedundantHigherOrderMapUsage: @@ -707,61 +707,61 @@ style: active: true SerialVersionUIDInSerializableClass: active: true - SpacingAfterPackageDeclaration: - active: false - StringShouldBeRawString: - active: false - maxEscapedCharacterCount: 2 - ignoredCharacters: [] +# SpacingAfterPackageDeclaration: +# active: false +# StringShouldBeRawString: +# active: false +# maxEscapedCharacterCount: 2 +# ignoredCharacters: [] ThrowsCount: #限制函数中抛出语句的数量,函数应该有明确的throw语句 active: true max: 2 - excludeGuardClauses: false +# excludeGuardClauses: false TrailingWhitespace: active: false - TrimMultilineRawString: - active: false - trimmingMethods: - - 'trimIndent' - - 'trimMargin' +# TrimMultilineRawString: +# active: false +# trimmingMethods: +# - 'trimIndent' +# - 'trimMargin' UnderscoresInNumericLiterals: active: false - acceptableLength: 4 - allowNonStandardGrouping: false +# acceptableLength: 4 +# allowNonStandardGrouping: false UnnecessaryAnnotationUseSiteTarget: active: false UnnecessaryApply: active: true - UnnecessaryBackticks: - active: false - UnnecessaryBracesAroundTrailingLambda: - active: false - UnnecessaryFilter: - active: true +# UnnecessaryBackticks: +# active: false +# UnnecessaryBracesAroundTrailingLambda: +# active: false +# UnnecessaryFilter: +# active: true UnnecessaryInheritance: #此规则报告不必要的超类型 active: true - UnnecessaryInnerClass: - active: false +# UnnecessaryInnerClass: +# active: false UnnecessaryLet: active: false UnnecessaryParentheses: active: false - allowForUnclearPrecedence: false - UnusedImport: - active: false - UnusedParameter: - active: true - allowedNames: 'ignored|expected' +# allowForUnclearPrecedence: false +# UnusedImport: +# active: false +# UnusedParameter: +# active: true +# allowedNames: 'ignored|expected' UnusedPrivateClass: active: true UnusedPrivateMember: active: true allowedNames: '' - UnusedPrivateProperty: - active: true - allowedNames: '_|ignored|expected|serialVersionUID' - UseAnyOrNoneInsteadOfFind: - active: true +# UnusedPrivateProperty: +# active: true +# allowedNames: '_|ignored|expected|serialVersionUID' +# UseAnyOrNoneInsteadOfFind: +# active: true UseArrayLiteralsInAnnotations: active: true UseCheckNotNull: @@ -777,26 +777,26 @@ style: active: false UseIfInsteadOfWhen: active: false - ignoreWhenContainingVariableDeclaration: false - UseIsNullOrEmpty: - active: true - UseLet: - active: false - UseOrEmpty: - active: true +# ignoreWhenContainingVariableDeclaration: false +# UseIsNullOrEmpty: +# active: true +# UseLet: +# active: false +# UseOrEmpty: +# active: true UseRequire: active: true UseRequireNotNull: active: true - UseSumOfInsteadOfFlatMapSize: - active: false +# UseSumOfInsteadOfFlatMapSize: +# active: false UselessCallOnNotNull: active: true UtilityClassWithPublicConstructor: active: true VarCouldBeVal: active: true - ignoreLateinitVar: false +# ignoreLateinitVar: false WildcardImport: active: true excludeImports: diff --git a/core/mogo-core-res/src/main/java/com/mogo/eagle/core/widget/media/video/NoticeSimpleVideoPlayer.kt b/core/mogo-core-res/src/main/java/com/mogo/eagle/core/widget/media/video/NoticeSimpleVideoPlayer.kt index 5aece47920..c89a65f341 100644 --- a/core/mogo-core-res/src/main/java/com/mogo/eagle/core/widget/media/video/NoticeSimpleVideoPlayer.kt +++ b/core/mogo-core-res/src/main/java/com/mogo/eagle/core/widget/media/video/NoticeSimpleVideoPlayer.kt @@ -1,5 +1,6 @@ package com.mogo.eagle.core.widget.media.video +import android.annotation.SuppressLint import android.content.Context import android.os.Build import android.util.AttributeSet @@ -212,6 +213,7 @@ class NoticeSimpleVideoPlayer : StandardGSYVideoPlayer { } } + @SuppressLint("ObsoleteSdkInt") override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { super.onSizeChanged(w, h, oldw, oldh) if (!mIfCurrentIsFullscreen) { diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/koom/KoomInitTask.kt b/foudations/mogo-commons/src/main/java/com/mogo/commons/koom/KoomInitTask.kt index f442e7e573..1d0a46ea0c 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/koom/KoomInitTask.kt +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/koom/KoomInitTask.kt @@ -1,5 +1,6 @@ package com.mogo.commons.koom +import android.annotation.SuppressLint import android.app.Application import android.os.Build import com.kwai.koom.base.CommonConfig @@ -8,6 +9,7 @@ import com.kwai.koom.base.MonitorManager object KoomInitTask : InitTask { + @SuppressLint("ObsoleteSdkInt") override fun init(application: Application) { val config = CommonConfig.Builder() .setApplication(application) // Set application diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b850a7a179..050b1a2bf7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Sep 22 11:53:55 CST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 4c07709a502bf971402c80958c7adcf1305c3448 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Wed, 27 Sep 2023 17:54:37 +0800 Subject: [PATCH 10/24] [3.4.0-map-sdk] --- build.gradle | 12 +-- codequality/detekt.gradle | 26 ++++-- codequality/detekt.yml | 26 +++--- codequality/pmd.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../com/autonavi/nge/dm/INavigationCore.aidl | 85 ------------------- .../map/sdk/inner/map/MapController.kt | 6 +- 7 files changed, 44 insertions(+), 115 deletions(-) delete mode 100644 libraries/mapmodule/src/main/aidl/com/autonavi/nge/dm/INavigationCore.aidl diff --git a/build.gradle b/build.gradle index 40ba76905b..190f5f0714 100644 --- a/build.gradle +++ b/build.gradle @@ -74,14 +74,14 @@ allprojects { } if (isCodeInspectEnable ) { -// def basePath = new File(codequality, 'code_inspect_increment.gradle').path -// apply from: "$basePath" -// def pmdPath = new File(codequality, 'pmd.gradle').path -// apply from: "$pmdPath" + def basePath = new File(codequality, 'code_inspect_increment.gradle').path + apply from: "$basePath" + def pmdPath = new File(codequality, 'pmd.gradle').path + apply from: "$pmdPath" def detektPath = new File(codequality, 'detekt.gradle').path apply from: "$detektPath" -// def codeInspectPath = new File(codequality, 'code_inspect.gradle').path -// apply from: "$codeInspectPath" + def codeInspectPath = new File(codequality, 'code_inspect.gradle').path + apply from: "$codeInspectPath" } } diff --git a/codequality/detekt.gradle b/codequality/detekt.gradle index 1129174a38..e57ef8c5cc 100644 --- a/codequality/detekt.gradle +++ b/codequality/detekt.gradle @@ -1,6 +1,6 @@ apply plugin: 'io.gitlab.arturbosch.detekt' -def pmdConfigPath = rootProject.file("codequality").path +def configPath = rootProject.file("codequality").path detekt { toolVersion = "1.15.0" @@ -10,13 +10,13 @@ detekt { "src/driverm1/java" ) //将配置文件应用于detekt的默认配置文件之上 - buildUponDefaultConfig = true + buildUponDefaultConfig = false //规则集 - config.setFrom("${pmdConfigPath}/detekt.yml") + config.setFrom("${configPath}/detekt.yml") //指定基准文件。在detekt的后续运行中,所有发现都存储在此文件中 -// baseline = file("${pmdConfigPath}/baseline.xml") - +// baseline = file("${configPath}/baseline.xml") + ignoreFailures = true // Android: Don't create tasks for the specified build types (e.g. "release") // ignoredBuildTypes = ["release"] // Android: Don't create tasks for the specified build flavor (e.g. "production") @@ -25,7 +25,7 @@ detekt { // ignoredVariants = ["productionRelease"] } -tasks.detekt.jvmTarget = "1.11" +tasks.detekt.jvmTarget = "1.8" tasks.named("detekt").configure { reports { @@ -33,7 +33,21 @@ tasks.named("detekt").configure { html { enabled = true // Path where HTML report will be stored (default: `build/reports/detekt/detekt.html`) + destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.xml") + } + xml { + enabled = true destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") } + txt { + enabled = false +// destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.txt") + } + sarif { + // Enable/Disable SARIF report (default: false) + enabled = true + // Path where SARIF report will be stored (default: `build/reports/detekt/detekt.sarif`) + destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.sarif") + } } } diff --git a/codequality/detekt.yml b/codequality/detekt.yml index 492f87f811..327c7525c2 100644 --- a/codequality/detekt.yml +++ b/codequality/detekt.yml @@ -287,12 +287,12 @@ exceptions: exceptionNames: - 'ArrayIndexOutOfBoundsException' - 'Error' - - 'Exception' +# - 'Exception' - 'IllegalMonitorStateException' - 'IndexOutOfBoundsException' - 'NullPointerException' - 'RuntimeException' - - 'Throwable' +# - 'Throwable' allowedExceptionNameRegex: '_|(ignore|expected).*' TooGenericExceptionThrown: #规则报告类型过于通用的抛出异常。对于当前发生的情况,最好抛出特定的异常 active: true @@ -545,8 +545,8 @@ style: active: false DataClassContainsFunctions: active: false - conversionFunctionPrefix: - - 'to' +# conversionFunctionPrefix: +# - 'to' # allowOperators: false DataClassShouldBeImmutable: active: false @@ -623,7 +623,7 @@ style: active: true ignoreOverridableFunction: true # ignoreActualFunction: true - excludedFunctions: [] +# excludedFunctions: [] LoopWithTooManyJumpStatements: active: true maxJumpCount: 1 @@ -695,14 +695,14 @@ style: active: true RedundantVisibilityModifierRule: active: false - ReturnCount: #在一个函数中有许多出口点可能会造成混乱,并影响代码的可读性。 - active: true - max: 2 - excludedFunctions: - - 'equals' - excludeLabeled: false - excludeReturnFromLambda: true - excludeGuardClauses: false +# ReturnCount: #在一个函数中有许多出口点可能会造成混乱,并影响代码的可读性。 +# active: false +# max: 2 +# excludedFunctions: +# - 'equals' +# excludeLabeled: false +# excludeReturnFromLambda: false +# excludeGuardClauses: false SafeCast: active: true SerialVersionUIDInSerializableClass: diff --git a/codequality/pmd.gradle b/codequality/pmd.gradle index 359264c4ee..3f2524f724 100644 --- a/codequality/pmd.gradle +++ b/codequality/pmd.gradle @@ -4,7 +4,7 @@ def pmdConfigPath = rootProject.file("codequality").path task pmd(type:Pmd){ //忽略失败,如果设置为true,检测出bug会停止task - ignoreFailures = false + ignoreFailures = true consoleOutput = true //filter路径 ruleSetFiles = files("${pmdConfigPath}/custom-pmd-ruleset.xml") //新增rules diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 050b1a2bf7..b850a7a179 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Sep 22 11:53:55 CST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/libraries/mapmodule/src/main/aidl/com/autonavi/nge/dm/INavigationCore.aidl b/libraries/mapmodule/src/main/aidl/com/autonavi/nge/dm/INavigationCore.aidl deleted file mode 100644 index bea7074392..0000000000 --- a/libraries/mapmodule/src/main/aidl/com/autonavi/nge/dm/INavigationCore.aidl +++ /dev/null @@ -1,85 +0,0 @@ -//package com.autonavi.nge.dm; -// -//import android.os.IBinder; -//import com.autonavi.nge.guidance.RouteBook; -//import com.autonavi.nge.guidance.NaviInfo; -//import com.autonavi.nge.guidance.RouteImage; -//import com.autonavi.nge.guidance.LaneMask; -//import com.autonavi.nge.obj.Category; -//import com.autonavi.nge.obj.UpdateRegion; -//import com.autonavi.nge.trafficInfo.TMCID; -//import com.autonavi.nge.search.SPPoiItem; -//import com.autonavi.nge.search.SPCategories; -//import com.autonavi.nge.search.SPQuery; -//import com.autonavi.nge.search.SPSearchResult; -//import com.autonavi.nge.map.LonLat; -//import com.autonavi.nge.guidance.GuidanceStatListener; -//interface INavigationCore { -//// IBinder getHandler(); -// void Routing_SetOrigin(float lon, float lat, int sessionid); -// void Routing_SetDest(float lon, float lat, int sessionid); -// void Routing_GetRoute(int sessionid); -// boolean Routing_GetStatus(int sessionid); -// void Routing_Reset(int sessionid); -// void Routing_ClearTour(int sessionid); -// void RoutingSetCostModel(int model, int sessionid); -// void RoutingSetAvoidHighway(boolean isAvoidHighway, int sessionid); -// void RoutingSetAvoidToll(boolean isAvoidToll, int sessionid); -// -// void Traffic_Update(in List ids, int evt); -// void Traffic_UpdateByTile(int tile, in int[] ids, in byte[] speeds); -// void RoutingSetUseTraffic(boolean useTraffic, int sessionid); -// int RoutingGetRouteNum(int sessionid); -// int RoutingGetLength(int route, int sessionid); -// int RoutingGetSTime(int route, int sessionid); -// int RoutingGetDTime(int route, int sessionid); -// void addwaypoint(float lon, float lat, int heading, int sessionid); -// void clearwaypoints(int sessionid); -// -// void Guidance_UpdatePosition(float lon, float lat, float speed, float heading); -// void Guidance_StartNavi(int type); -// void Guidance_StopNavi(); -// void Guidance_SetSimSpeed(int speed); -// void Guidance_PauseSimNavi(); -// void Guidance_ResumeSimNavi(); -// RouteBook Guidance_RouteBook(int session,int start,int end); -// NaviInfo Guidance_NaviInfo(); -// NaviInfo GetNaviInfo(in byte[] datas); -// String Guidance_TTS(); -// RouteImage Guidance_Image(int imageUr,int imageBg,int imageArrow,int type); -// LaneMask Guidance_LaneMask(); -// double Guidance_getRoadAngle(); -// -// List Search_getSearchResult(int productId, double lon, double lat, double radius, int kindfilter, int updateregionId, String keyWord, int pageIdx, int searchType); -// SPPoiItem getPoiItemByPoiId(int poiId); -// List getPoiItemListByLonLat(int prodId, int urId, float lon, float lat, int pageCount, int pageIdx); -// List queryPoiItemByCircle(float centerLon,float centerLat,float radius); -// List queryPoiItemByRect(float topLeftLon,float topLeftLat,float bottomRightLon,float bottomRightLat); -// List queryPoiItemByPolygon(in List latLonPoints); -// List getFTSDataByDA( int urid, String keyStr, int keytype, int maxResultCount); -// List getInputResult(int productId, int updateregionId, String inputStr); -// List getInputResultByDA(); -// List getCatList(int urid); -// List getURListByDA(int prodid); -// void play(String text,boolean forcePlay); -// -// int RoutingGetSearchedCnt(int route, int sessionid); -// -// int [] getMemoryInfo(); -// -// void startServer(); -// -// void stopServer(); -// -// int getMDSVersion(); -// String getDataVersion(); -// String getCopyRight(); -// String getCompilerVersion(); -// -// void onGuidanceStatusChanged(int statCode, in byte[] datas); -// -// void setGuidanceStatListener(GuidanceStatListener listener); -// -// SPCategories getAllPoiCategories(int languageCode); -// List getPoiItemList(in SPQuery query); -//} diff --git a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/map/MapController.kt b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/map/MapController.kt index be37e8c49a..6087b945b2 100644 --- a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/map/MapController.kt +++ b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/map/MapController.kt @@ -1025,7 +1025,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie val data = polylineOptions.lonLats var polyline: Polyline? = null try { - if (data == null || data.size <= 1) { + if (data.size <= 1) { throw RuntimeException("传入的坐标数必须大于1") } val strOptionsJson = JSON.toJSONString(polylineOptions) @@ -1054,7 +1054,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie val colorSize = colorValues?.size ?: 0 var polyline: Polyline? = null try { - if (data == null || data.size <= 1) { + if (data.size <= 1) { throw RuntimeException("传入的坐标数必须大于1") } if (polylineOptions.getIsGradient() && colorSize > data.size) { @@ -1090,7 +1090,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie val data = deadZoneOptions.getPosition() var deadZone: DeadZone? = null try { - if (data == null || data.size <= 1) { + if (data.size <= 1) { throw RuntimeException("传入的坐标数必须大于1") } val strOptionsJson = JSON.toJSONString(deadZoneOptions) From 636daf05d96ce79accb670edf8e60ef111699f3f Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Thu, 28 Sep 2023 12:17:11 +0800 Subject: [PATCH 11/24] =?UTF-8?q?[6.1.0]=201=E3=80=81=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E6=BC=94=E7=BB=83=E5=8D=95=E5=88=B0=E8=BE=BE=E7=AB=99=E7=82=B9?= =?UTF-8?q?,=20=E6=9A=82=E5=81=9C=E6=8E=A5=E5=8D=95->=20=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E6=8E=A5=E5=8D=95=20=E5=89=8D=E5=BE=80=E6=A0=87=E5=AE=9A?= =?UTF-8?q?=E7=AB=99=E7=82=B9=E5=88=B0=E7=AB=99=E6=8E=A5=E5=8F=A3=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mogo/och/taxi/ui/task/TaxiTaskModel.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/task/TaxiTaskModel.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/task/TaxiTaskModel.kt index c1d5857c2f..745dfa717b 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/task/TaxiTaskModel.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/task/TaxiTaskModel.kt @@ -1322,6 +1322,7 @@ object TaxiTaskModel { */ fun clearCurrentOCHOrder() { clearAutopilotControlParameters() + mIsArrivedSiteStartTag = false isRestartAutopilot = false if (FunctionBuildConfig.isDemoMode) { // 当美化模式(演示模式)开启时: 取消或订单已完成时,置false From 06a96b31d3341d4a007d5bc521db7a9655ca9007 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Thu, 28 Sep 2023 15:20:17 +0800 Subject: [PATCH 12/24] [3.4.0-map-sdk] --- .gitignore | 3 +-- .gitlab-ci.yml | 9 +++++++++ codequality/code_inspect_increment.gradle | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitignore b/.gitignore index f11e27d274..3ec053d928 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,4 @@ /build /captures .externalNativeBuild -.cxx -.gitlab-ci.yml \ No newline at end of file +.cxx \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000..f6b2ad0e0e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,9 @@ +stages: + - analyze + +inspect java and kotlin codes: + tags: + - apk + - android + stage: analyze + diff --git a/codequality/code_inspect_increment.gradle b/codequality/code_inspect_increment.gradle index 4b5e517f92..60baf24322 100644 --- a/codequality/code_inspect_increment.gradle +++ b/codequality/code_inspect_increment.gradle @@ -8,7 +8,7 @@ ext { } /** - * 增量开关 + * 增量开关, 给 lint 插件做增量扫描使用 */ def isIncrement = false From e957b6b5d61dc732dbd52cdaf7a68d91a94a78df Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Thu, 28 Sep 2023 15:30:56 +0800 Subject: [PATCH 13/24] =?UTF-8?q?[6.1.0][Fix]=E8=A7=A3=E5=86=B3=E5=B9=B3?= =?UTF-8?q?=E8=A1=8C=E9=A9=BE=E9=A9=B6=E7=8A=B6=E6=80=81=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84UI=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmi/ui/widget/ParallelDriveView.kt | 64 ++++++++++--------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt index 84742609d3..fead1ec4c7 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt @@ -93,16 +93,19 @@ class ParallelDriveView @JvmOverloads constructor( reqParaDrive() listener?.onReqClick() } + APP_REQUESTING -> { cancelParaDrive() Log.d(TAG, "Click-请求已取消") ToastUtils.showShort("请求已取消!") checkAvailableAndUpdateUI() } + AD_REQUESTING -> { Log.d(TAG, "Click-自动驾驶正在请求平行驾驶") ToastUtils.showShort("自动驾驶正在请求平行驾驶") } + UNAVAILABLE -> { Log.d(TAG, "Click-请P档驻车并松开油门刹车后请求") ToastUtils.showShort("请P档驻车并松开油门刹车后请求") @@ -118,41 +121,42 @@ class ParallelDriveView @JvmOverloads constructor( override fun onAutopilotStatusResponse(state: Int) { super.onAutopilotStatusResponse(state) - if (state != autopilotState) { - synchronized(this) { - when (state) { - 7 -> { - if (this.autopilotState != 7) { - isAutoDriving = false - Log.d(TAG, "onAutopilotStatusResponse-7") - ThreadUtils.runOnUiThread({ - updateUI(PARALLEL_DRIVING) - }, ThreadUtils.MODE.QUEUE) - } - } + when (state) { + 7 -> { + if (this.autopilotState != 7) { + isAutoDriving = false + Log.d(TAG, "onAutopilotStatusResponse-7") + ThreadUtils.runOnUiThread({ + updateUI(PARALLEL_DRIVING) + }, ThreadUtils.MODE.QUEUE) + } + } - 2 -> { - if (this.autopilotState != state) { - isAutoDriving = true - Log.d(TAG, "onAutopilotStatusResponse-2") - } - } - - else -> { - if (this.autopilotState != state) { - isAutoDriving = false - Log.d(TAG, "onAutopilotStatusResponse-else") - if (this.autopilotState == 7) { - ThreadUtils.runOnUiThread({ - checkAvailableAndUpdateUI() - }, ThreadUtils.MODE.QUEUE) - } - } + 2 -> { + if (this.autopilotState != state) { + isAutoDriving = true + Log.d(TAG, "onAutopilotStatusResponse-2") + if (this.autopilotState == 7) { + ThreadUtils.runOnUiThread({ + checkAvailableAndUpdateUI() + }, ThreadUtils.MODE.QUEUE) + } + } + } + + else -> { + if (this.autopilotState != state) { + isAutoDriving = false + Log.d(TAG, "onAutopilotStatusResponse-else") + if (this.autopilotState == 7) { + ThreadUtils.runOnUiThread({ + checkAvailableAndUpdateUI() + }, ThreadUtils.MODE.QUEUE) } } - this.autopilotState = state } } + this.autopilotState = state } override fun onParallelDrivingAbility( From e37d19d80c35090d29aa59f4860e141cf21405ec Mon Sep 17 00:00:00 2001 From: zhongchao Date: Thu, 28 Sep 2023 15:32:22 +0800 Subject: [PATCH 14/24] [6.1.0] add chain log --- .../datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt | 7 +++++++ .../com/mogo/eagle/core/data/deva/chain/ChainConstant.kt | 1 + 2 files changed, 8 insertions(+) diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt index 48891547c5..0263d37654 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt @@ -17,6 +17,7 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_AD import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ADAS_VEHICLE import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ADAS_CAR_CONFIG import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ADAS_CAR_LOC +import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ADAS_PARALLEL import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ADAS_P_ACTIONS import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ADAS_P_OBJECTS import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_ADAS_STATUS_QUERY_RESP @@ -771,6 +772,12 @@ class MoGoAdasListenerImpl : OnAdasListener { * @param sysTime 当前时间戳 * @param parallelTaskProcessNotice 数据 */ + @ChainLog( + linkChainLog = CHAIN_TYPE_SOCKET_AUTOPILOT, + linkCode = CHAIN_SOURCE_ADAS, + nodeAliasCode = CHAIN_CODE_ADAS_PARALLEL, + paramIndexes = [0, 1, 2, 4] + ) override fun onParallelDrivingResp( header: MessagePad.Header, messageType: AiCloudTask.MessageType, diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/chain/ChainConstant.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/chain/ChainConstant.kt index e393ead0aa..670ce998aa 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/chain/ChainConstant.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/deva/chain/ChainConstant.kt @@ -70,6 +70,7 @@ class ChainConstant { const val CHAIN_CODE_ADAS_P_OBJECTS = "CHAIN_CODE_ADAS_P_OBJECTS" const val CHAIN_CODE_ADAS_P_ACTIONS = "CHAIN_CODE_ADAS_P_ACTIONS" const val CHAIN_CODE_ADAS_STATUS_QUERY_RESP = "CHAIN_CODE_ADAS_STATUS_QUERY_RESP" + const val CHAIN_CODE_ADAS_PARALLEL = "CHAIN_CODE_ADAS_PARALLEL" const val CHAIN_CODE_RECORD_NATIVE_LEAK = "CHAIN_CODE_RECORD_NATIVE_LEAK" const val CHAIN_CODE_RECORD_ANR = "CHAIN_CODE_RECORD_ANR" From 07865d1123614567a363ab98d7ea226bd44efc69 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Thu, 28 Sep 2023 15:50:21 +0800 Subject: [PATCH 15/24] =?UTF-8?q?[6.1.0][Opt]=E5=8E=BB=E6=8E=89=E5=86=97?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmi/ui/widget/ParallelDriveView.kt | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt index fead1ec4c7..6d3b9e4e4c 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ParallelDriveView.kt @@ -123,36 +123,30 @@ class ParallelDriveView @JvmOverloads constructor( super.onAutopilotStatusResponse(state) when (state) { 7 -> { - if (this.autopilotState != 7) { - isAutoDriving = false - Log.d(TAG, "onAutopilotStatusResponse-7") + isAutoDriving = false + Log.d(TAG, "onAutopilotStatusResponse-7") + ThreadUtils.runOnUiThread({ + updateUI(PARALLEL_DRIVING) + }, ThreadUtils.MODE.QUEUE) + } + + 2 -> { + isAutoDriving = true + Log.d(TAG, "onAutopilotStatusResponse-2") + if (this.autopilotState == 7) { ThreadUtils.runOnUiThread({ - updateUI(PARALLEL_DRIVING) + checkAvailableAndUpdateUI() }, ThreadUtils.MODE.QUEUE) } } - 2 -> { - if (this.autopilotState != state) { - isAutoDriving = true - Log.d(TAG, "onAutopilotStatusResponse-2") - if (this.autopilotState == 7) { - ThreadUtils.runOnUiThread({ - checkAvailableAndUpdateUI() - }, ThreadUtils.MODE.QUEUE) - } - } - } - else -> { - if (this.autopilotState != state) { - isAutoDriving = false - Log.d(TAG, "onAutopilotStatusResponse-else") - if (this.autopilotState == 7) { - ThreadUtils.runOnUiThread({ - checkAvailableAndUpdateUI() - }, ThreadUtils.MODE.QUEUE) - } + isAutoDriving = false + Log.d(TAG, "onAutopilotStatusResponse-else") + if (this.autopilotState == 7) { + ThreadUtils.runOnUiThread({ + checkAvailableAndUpdateUI() + }, ThreadUtils.MODE.QUEUE) } } } From 5d222c70fb0467545dcc3b3ed49ed2737c256805 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Thu, 28 Sep 2023 16:29:26 +0800 Subject: [PATCH 16/24] [3.4.0-map-sdk]add yml and config set --- .gitlab-ci.yml | 18 +++++++++++++++++- config.gradle | 6 ------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f6b2ad0e0e..7ca3bfff2a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,4 +6,20 @@ inspect java and kotlin codes: - apk - android stage: analyze - + script: + - echo "$CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA $CI_COMMIT_BRANCH" + - echo "$CI_JOB_STAGE}_reports_${CI_PROJECT_NAME}_${CI_BUILD_REF_NAME}" + - ./gradlew runCodeInspect + before_script: + - source change_java_version + artifacts: + name: "$CI_JOB_STAGE}_reports_${CI_PROJECT_NAME}_$CI_COMMIT_REF_SLUG" + when: on_failure + expire_in: 1 days + paths: + - "build/reports/*" + only: + - "$CI_COMMIT_BRANCH" + except: + - master + allow_failure: false diff --git a/config.gradle b/config.gradle index 01d3248be9..108f48c3d8 100644 --- a/config.gradle +++ b/config.gradle @@ -230,14 +230,8 @@ ext { block_detector : "com.mogo.eagle.core.block:runtime:10.0.21" ] android = [ - launcherApplicationId : "com.mogo.launcher", - independentApplicationId : "com.mogo.launcher.app", fLauncherApplicationId : "com.mogo.launcher.f", - bydautoIndependentApplicationId: "com.mogo.launcher.app.bydauto", fLauncherAmapApiValue : "ace34d685cc04836c03905e4d1536125", - bydautoIndependentApiValue : "b1e1d527b02a493913c50985827c943a", - commonLauncherAmapApiValue : "a36b9f7b086fa3951bb35338a5a06dd3", - commonIndependentAmapApiValue : "1c3fbc5f5e183619ffb1e7bc01e6751f", compileSdkVersion : 33, buildToolsVersion : "29.0.2", minSdkVersion : 23, From dfb2400835fbd60018abb8b34d7445160edef67f Mon Sep 17 00:00:00 2001 From: zhongchao Date: Thu, 28 Sep 2023 17:36:39 +0800 Subject: [PATCH 17/24] [3.4.0-map-sdk] fix yml --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7ca3bfff2a..6f35450937 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,8 +18,8 @@ inspect java and kotlin codes: expire_in: 1 days paths: - "build/reports/*" - only: - - "$CI_COMMIT_BRANCH" - except: - - master - allow_failure: false + only: + - "$CI_COMMIT_BRANCH" + except: + - master + allow_failure: true From 7b8d6881c66fcc61d8152a67084f3750dcb6f37a Mon Sep 17 00:00:00 2001 From: wangmingjun Date: Thu, 28 Sep 2023 17:43:08 +0800 Subject: [PATCH 18/24] =?UTF-8?q?[6.1.0]=20=E7=82=B9=E5=87=BB=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=B9=B3=E8=A1=8C=E9=A9=BE=E9=A9=B6=E6=97=B6,?= =?UTF-8?q?=E6=97=A0=E4=BB=BB=E5=8A=A1=E4=B8=8D=E5=8E=BB=E6=B5=81=E8=BD=AC?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mogo/och/taxi/ui/task/TaxiCurrentTaskViewModel.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/task/TaxiCurrentTaskViewModel.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/task/TaxiCurrentTaskViewModel.kt index 62ae3073ba..3905c64d3b 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/task/TaxiCurrentTaskViewModel.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/task/TaxiCurrentTaskViewModel.kt @@ -303,6 +303,10 @@ class TaxiCurrentTaskViewModel : BaseViewModel(), */ override fun onStopAutopilot() { UiThreadHandler.removeCallbacks(startTaskRunnable) + if (!TaxiTaskModel.checkCurrentTaskCondition()) { + d(TAG, "onStopAutopilot: 无任务无需流转状态") + return + } startTask(false) } From 3192211cc8a4d54e5bf965e5f52567b04c4a2300 Mon Sep 17 00:00:00 2001 From: yangyakun Date: Sat, 7 Oct 2023 09:59:54 +0800 Subject: [PATCH 19/24] [6.1.0] [gradle] [reset] --- config.gradle | 2 +- gradle/ext.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config.gradle b/config.gradle index 108f48c3d8..106d6d7919 100644 --- a/config.gradle +++ b/config.gradle @@ -6,7 +6,7 @@ ext { //插件工具存放目录 codequality = new File(projectDir, 'codequality') //静态代码检查开关 - isCodeInspectEnable = true + isCodeInspectEnable = false dependencies = [ // androidx diff --git a/gradle/ext.gradle b/gradle/ext.gradle index 7ebb4b74a6..2337daae66 100644 --- a/gradle/ext.gradle +++ b/gradle/ext.gradle @@ -1,5 +1,5 @@ ext { - gradle_version = '4.0.1' + gradle_version = '3.5.3' kotlin_plugin_version = '1.5.30' plugin_version = '10.0.0_mogo' service_chain_version = '5.3.6' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b850a7a179..1b511f962f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Sep 22 11:53:55 CST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 572656a19f5534d707917176ba6d16ae209f46ae Mon Sep 17 00:00:00 2001 From: zhongchao Date: Sat, 7 Oct 2023 10:20:39 +0800 Subject: [PATCH 20/24] [6.1.0] bash note --- codequality/code_inspect_increment.gradle | 77 ++++++++++++----------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/codequality/code_inspect_increment.gradle b/codequality/code_inspect_increment.gradle index 60baf24322..5893cd5223 100644 --- a/codequality/code_inspect_increment.gradle +++ b/codequality/code_inspect_increment.gradle @@ -27,12 +27,13 @@ def getResultFromCmd(String cmd) { standardOutput = out }.assertNormalExitValue() } else { - project.exec { - ExecSpec execSpec -> - executable 'bash' - args '-c', "$cmd" - standardOutput = out - }.assertNormalExitValue() + // jenkins 打包出异常,需要区分linux和macOS +// project.exec { +// ExecSpec execSpec -> +// executable 'bash' +// args '-c', "$cmd" +// standardOutput = out +// }.assertNormalExitValue() } return out.toString().trim() } @@ -149,38 +150,38 @@ def saveCommitFiles(Object[] commitFiles) { task runCodeInspectIncrement { - group = "codeInspect" - description = "存储增量文件" - def commitJavaFiles = new ArrayList() - def commitKotlinFiles = new ArrayList() - - def commitFiles = new Object[0] - if (isIncrement) { - commitFiles = getCommitFiles() - } else { - commitFiles = getAllFiles() - } - saveCommitFiles(commitFiles) - if (commitFiles != null && commitFiles.length > 0) { - def projectStartPath = getProjectStartPath() - for (String s : commitFiles) { - def commitFile = s.toString().trim() - if (commitFile.endsWith('.kt')) { - commitKotlinFiles.add(commitFile.substring(projectStartPath.length() + 1)) - } else if (commitFile.endsWith('.java')) { - commitJavaFiles.add(commitFile.substring(projectStartPath.length() + 1)) - } - } - } - if (!commitKotlinFiles.isEmpty()) { - logger.lifecycle("${project.name} commitKotlinFiles:$commitKotlinFiles") - } - if (!commitJavaFiles.isEmpty()) { - logger.lifecycle("${project.name} commitJavaFiles:$commitJavaFiles") - } - project.setProperty("commitKotlinFiles", commitKotlinFiles) - project.setProperty("commitJavaFiles", commitJavaFiles) - project.setProperty("commitAuthor", getCommitAuthor()) +// group = "codeInspect" +// description = "存储增量文件" +// def commitJavaFiles = new ArrayList() +// def commitKotlinFiles = new ArrayList() +// +// def commitFiles = new Object[0] +// if (isIncrement) { +// commitFiles = getCommitFiles() +// } else { +// commitFiles = getAllFiles() +// } +// saveCommitFiles(commitFiles) +// if (commitFiles != null && commitFiles.length > 0) { +// def projectStartPath = getProjectStartPath() +// for (String s : commitFiles) { +// def commitFile = s.toString().trim() +// if (commitFile.endsWith('.kt')) { +// commitKotlinFiles.add(commitFile.substring(projectStartPath.length() + 1)) +// } else if (commitFile.endsWith('.java')) { +// commitJavaFiles.add(commitFile.substring(projectStartPath.length() + 1)) +// } +// } +// } +// if (!commitKotlinFiles.isEmpty()) { +// logger.lifecycle("${project.name} commitKotlinFiles:$commitKotlinFiles") +// } +// if (!commitJavaFiles.isEmpty()) { +// logger.lifecycle("${project.name} commitJavaFiles:$commitJavaFiles") +// } +// project.setProperty("commitKotlinFiles", commitKotlinFiles) +// project.setProperty("commitJavaFiles", commitJavaFiles) +// project.setProperty("commitAuthor", getCommitAuthor()) } From 51493b6c4961e0ac603c1644251a3dcdee78c37d Mon Sep 17 00:00:00 2001 From: zhongchao Date: Sat, 7 Oct 2023 11:54:46 +0800 Subject: [PATCH 21/24] [6.1.0] close pmd of kotlin detekt --- codequality/custom-pmd-ruleset.xml | 1 + codequality/pmd.gradle | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/codequality/custom-pmd-ruleset.xml b/codequality/custom-pmd-ruleset.xml index 884a4702e7..f8260e7b3f 100644 --- a/codequality/custom-pmd-ruleset.xml +++ b/codequality/custom-pmd-ruleset.xml @@ -9,6 +9,7 @@ + .*.kt .*/R.java .*/gen/.* .*Dagger*.* diff --git a/codequality/pmd.gradle b/codequality/pmd.gradle index 3f2524f724..1e196ef19b 100644 --- a/codequality/pmd.gradle +++ b/codequality/pmd.gradle @@ -12,7 +12,7 @@ task pmd(type:Pmd){ //检测资源路径 source 'src/main/java','src/jinlvvan/java','src/driverm1/java' //排除项 - exclude '**/gen/**' + exclude '**/gen/**,*.kt' reports { xml.getRequired().set(false) From 3a307c870b4566355a3be0f5401abe981716359c Mon Sep 17 00:00:00 2001 From: renwj Date: Sat, 7 Oct 2023 14:59:35 +0800 Subject: [PATCH 22/24] =?UTF-8?q?[6.1.0][=E5=BA=94=E7=94=A8=E5=8D=87?= =?UTF-8?q?=E7=BA=A7]=20=E6=B7=BB=E5=8A=A0=E6=B8=A0=E9=81=93=E5=8F=8A?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../upgrade/UpgradeAppNetWorkManager.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/upgrade/UpgradeAppNetWorkManager.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/upgrade/UpgradeAppNetWorkManager.kt index 5938237bd3..7716227eb4 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/upgrade/UpgradeAppNetWorkManager.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/upgrade/UpgradeAppNetWorkManager.kt @@ -19,6 +19,8 @@ import com.mogo.eagle.core.network.* import com.mogo.eagle.core.network.utils.* import com.mogo.eagle.core.utilcode.download.Config import com.mogo.eagle.core.utilcode.kotlin.* +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.eagle.core.utilcode.mogo.getMisChannelCode import com.mogo.eagle.core.utilcode.mogo.logger.scene.* import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr import com.mogo.eagle.core.utilcode.util.* @@ -66,6 +68,7 @@ class UpgradeAppNetWorkManager private constructor() { "${ it.first } -> ${ it.second }" } } + itx["role"] = AppIdentityModeUtils.getMisChannelCode(FunctionBuildConfig.appIdentityMode) }) } Log.d(TAG, "getAppUpgradeInfo: -> records:" + records?.entries?.joinToString(",") { itx -> "key:${itx.key} -> value:[${itx.value.joinToString(",") { "${it.first},${it.second}" } }]"}) From 50be53e5502cee593abd5f751222332359a93328 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Sat, 7 Oct 2023 15:06:31 +0800 Subject: [PATCH 23/24] [6.1.0] code open detekt --- config.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.gradle b/config.gradle index 106d6d7919..108f48c3d8 100644 --- a/config.gradle +++ b/config.gradle @@ -6,7 +6,7 @@ ext { //插件工具存放目录 codequality = new File(projectDir, 'codequality') //静态代码检查开关 - isCodeInspectEnable = false + isCodeInspectEnable = true dependencies = [ // androidx From ac5402d8a2a634e9d98ce74eb84cbac8a82418f4 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Sat, 7 Oct 2023 17:27:28 +0800 Subject: [PATCH 24/24] [6.1.0] fix bug of detekt html output --- codequality/detekt.gradle | 7 ++++--- codequality/detekt.yml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/codequality/detekt.gradle b/codequality/detekt.gradle index e57ef8c5cc..bc451259e5 100644 --- a/codequality/detekt.gradle +++ b/codequality/detekt.gradle @@ -9,13 +9,14 @@ detekt { "src/jinlvvan/java", "src/driverm1/java" ) + parallel = false //将配置文件应用于detekt的默认配置文件之上 buildUponDefaultConfig = false //规则集 config.setFrom("${configPath}/detekt.yml") //指定基准文件。在detekt的后续运行中,所有发现都存储在此文件中 // baseline = file("${configPath}/baseline.xml") - + disableDefaultRuleSets = false ignoreFailures = true // Android: Don't create tasks for the specified build types (e.g. "release") // ignoredBuildTypes = ["release"] @@ -33,11 +34,11 @@ tasks.named("detekt").configure { html { enabled = true // Path where HTML report will be stored (default: `build/reports/detekt/detekt.html`) - destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.xml") + destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") } xml { enabled = true - destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.html") + destination = new File(new File("${project.rootProject.buildDir.path}/reports/detekt"), "${project.name}-detekt.xml") } txt { enabled = false diff --git a/codequality/detekt.yml b/codequality/detekt.yml index 327c7525c2..3128e1d0d2 100644 --- a/codequality/detekt.yml +++ b/codequality/detekt.yml @@ -40,7 +40,7 @@ output-reports: exclude: # - 'TxtOutputReport' # - 'XmlOutputReport' - - 'HtmlOutputReport' + # - 'HtmlOutputReport' # - 'MdOutputReport' # - 'SarifOutputReport'