如何在Sonarqube中激活一堆规则后找到抛出ArrayOutOfBoundsException的规则?

时间:2016-05-12 15:16:08

标签: java sonarqube sonarqube5.1

我最近在Sonarqube(5.1.1)中激活了以下规则:

  • squid:CallToDeprecatedMethod(" @ Deprecated"不应使用代码)
  • squid:S2737(" catch"条款不仅仅是重新抛出)
  • squid:S3398("私有"仅由内部类调用的方法应移至这些类)
  • squid:LeftCurlyBraceEndLineCheck(一个开放的大括号应该位于一行的末尾)
  • squid:S2445(在字段上同步的块不应包含对这些字段的新对象的分配)
  • pmd:BooleanGetMethodName(布尔获取方法名称)
  • squid:S1940(不应反转布尔检查)
  • pmd:CallSuperInConstructor(Call Super In Constructor)
  • 鱿鱼:S2147(捕捞量应合并)
  • findbugs:NM_LCASE_TOSTRING(Class定义了tostring();它应该是toString()吗?)
  • squid:RightCurlyBraceDifferentLineAsNextBlockCheck(关闭大括号和下一个"否则"," catch"""最终"关键字应该在两个不同的行上)
  • squid:S1451(应定义版权和许可证标题)
  • fb-contrib:AOM_ABSTRACT_OVERRIDDEN_METHOD(正确性 - 抽象方法覆盖具体实现)
  • fb-contrib:SPP_STUTTERED_ASSIGNMENT(正确性 - 方法连续两次为本地值指定值)
  • fb-contrib:SPP_TOSTRING_ON_STRING(正确性 - 方法调用String上的String())
  • fb-contrib:CCNE_COMPARE_CLASS_EQUALS_NAME(正确性 - 方法比较班级名称而不是比较班级)
  • fb-contrib:SLS_SUSPICIOUS_LOOP_SEARCH(正确性 - 方法在找到设置变量后继续循环而不中断)
  • fb-contrib:LSYC_LOCAL_SYNCHRONIZED_COLLECTION(正确性 - 方法创建基于局部变量的同步集合)
  • fb-contrib:OC_OVERZEALOUS_CASTING(正确性 - 方法手动强制转换作业的右侧而不是特定需要)
  • fb-contrib:LO_INCORRECT_NUMBER_OF_ANCHOR_PARAMETERS(正确性 - 方法将不正确数量的参数传递给SLF4J记录语句)
  • fb-contrib:SPP_USE_MATH_CONSTANT(正确性 - 方法使用非标准数学常量)
  • findbugs:RV_01_TO_INT(正确性 - 从0到1的随机值被强制为整数0)
  • findbugs:EQ_ALWAYS_FALSE(正确性 - 等于方法总是返回false)
  • findbugs:EQ_ALWAYS_TRUE(正确性 - 等于方法总是返回true)
  • findbugs:SKIPPED_CLASS_TOO_BIG(Dodgy - 类太大而无法分析)
  • FIXTEST(模板squid:S124:应该处理与正则表达式匹配的注释)
  • common-java:FailedUnitTests(应该修复失败的单元测试)
  • pmd:GodClass(上帝班)
  • findbugs:IIO_INEFFICIENT_INDEX_OF(String.indexOf(String)的使用效率低下)
  • findbugs:IIO_INEFFICIENT_LAST_INDEX_OF(String.lastIndexOf(String)的使用效率低下)
  • pmd-unit-tests:JUnitTestContainsTooManyAsserts(JUnit测试包含太多断言)
  • pmd-unit-tests:JUnitUseExpected(JUnit Use Expected)
  • pmd-unit-tests:JUnitSpelling(JUnit拼写)
  • pmd-unit-tests:JUnitStaticSuite(JUnit静态套件)
  • pmd-unit-tests:JUnitTestsShouldIncludeAssert(JUnit测试应包含断言)
  • pmd-unit-tests:JUnit4SuitesShouldUseSuiteAnnotation(JUnit4套件应使用套件注释)
  • pmd-unit-tests:JUnit4TestShouldUseAfterAnnotation(JUnit4测试应该在注释后使用)
  • pmd-unit-tests:JUnit4TestShouldUseBeforeAnnotation(JUnit4测试应在注释前使用)
  • pmd-unit-tests:JUnit4TestShouldUseTestAnnotation(JUnit4测试应该使用测试注释)
  • squid:S2701(不应在断言中使用文字布尔值)
  • pmd:LocalVariableCouldBeFinal(局部变量可能是最终的)
  • squid:S1845(方法和字段名称不应相同或仅以大写字母不同)
  • squid:S1659(不应在同一行上声明多个变量)
  • findbugs:IS2_INCONSISTENT_SYNC(多线程正确性 - 同步不一致)
  • fb-contrib:UEC_USE_ENUM_COLLECTIONS(Performance - Class使用普通集合或枚举类作为键的映射)
  • findbugs:HSC_HUGE_SHARED_STRING_CONSTANT(性能 - 巨大的字符串常量在多个类文件中重复)
  • findbugs:DM_BOOLEAN_CTOR(Performance - Method调用低效的布尔构造函数;改为使用Boolean.valueOf(...))
  • findbugs:DM_FP_NUMBER_CTOR(Performance - Method调用低效的浮点数构造函数;改为使用static valueOf)
  • findbugs:DM_STRING_VOID_CTOR(Performance - Method调用低效的新String()构造函数)
  • findbugs:DM_STRING_CTOR(Performance - Method调用低效的新String(String)构造函数
  • fb-contrib:NAB_NEEDLESS_BOOLEAN_CONSTANT_CONVERSION(性能 - 方法不必要地填充布尔常量)
  • fb-contrib:BSB_BLOATED_SYNCHRONIZED_BLOCK(性能 - 方法过度同步代码块)
  • fb-contrib:LO_APPENDED_STRING_IN_FORMAT_STRING(性能 - 方法将连接的字符串传递给Slf4j的格式字符串)
  • fb-contrib:UCPM_USE_CHARACTER_PARAMETERIZED_METHOD(性能 - 方法将长度为1的常量字符串传递给字符重写方法)
  • fb-contrib:SG_SLUGGISH_GUI(性能 - 方法在GUI线程中执行耗时的操作)
  • fb-contrib:DSOC_DUBIOUS_SET_OF_COLLECTIONS(性能 - 方法使用一组集合)
  • fb-contrib:SPP_USELESS_TERNARY(性能 - 方法使用三元运算符将布尔值转换为true或false)
  • fb-contrib:SPP_USE_GET0(Performance - Method在List上使用iterator()。next()来获取第一个项目)
  • fb-contrib:DDC_DOUBLE_DATE_COMPARISON(性能 - 方法使用两个日期比较)
  • findbugs:DM_NEXTINT_VIA_NEXTDOUBLE(性能 - 使用Random而不是nextDouble的nextInt方法生成随机整数)
  • pmd:RedundantFieldInitializer(Redundant Field Initializer)
  • squid:S2333(不应使用冗余修饰符)
  • findsecbugs:REDOS(安全 - Regex DOS(ReDOS))
  • squid:S1697(应该使用短路逻辑来防止条件中的空指针解引用)
  • pmd:SimplifyStartsWith(Simplify Starts With)
  • pmd-unit-tests:SimplifyBooleanAssertion(简化布尔断言)
  • fb-contrib:SPP_SERIALVER_SHOULD_BE_PRIVATE(Style - Class将serialVersionUID定义为非私有)
  • fb-contrib:NOS_NON_OWNED_SYNCHRONIZATION(样式 - 类使用非拥有变量进行同步)
  • fb-contrib:COM_COPIED_OVERRIDDEN_METHOD(样式 - 方法是使用其超类的方法的精确副本实现的)
  • fb-contrib:SPP_EMPTY_CASING(Style - Method将空字符串传递给equalsIgnoreCase或compareToIgnoreCase)
  • fb-contrib:CFS_CONFUSING_FUNCTION_SEMANTICS(样式 - 方法返回修改后的参数)
  • fb-contrib:STB_STACKED_TRY_BLOCKS(样式 - 方法堆叠类似的try / catch块)
  • fb-contrib:USBR_UNNECESSARY_STORE_BEFORE_RETURN(样式 - 方法将结果存储在本地,然后立即返回)
  • fb-contrib:LO_STUTTERED_MESSAGE(样式 - 方法在记录器中断断异常消息)
  • fb-contrib:MRC_METHOD_RETURNS_CONSTANT(样式 - 私有方法只返回一个常量值)
  • fb-contrib:UP_UNUSED_PARAMETER(样式 - 静态或私有方法有未使用的参数)
  • squid:S2699(测试应包括断言)
  • pmd:UnnecessaryFinalModifier(不必要的最终修饰符)
  • pmd:不必要的富有资格的名称(不必要的完全合格的名字)
  • pmd-unit-tests:UnnecessaryBooleanAssertion(不必要的布尔断言)
  • pmd:UseArraysAsList(使用数组作为列表)
  • pmd:UseConcurrentHashMap(使用ConcurrentHashMap)
  • pmd:UseIndexOfChar(使用字符索引)
  • pmd:UseStringBufferForStringAppends(对字符串追加使用字符串缓冲区)
  • pmd:UseStringBufferLength(使用字符串缓冲区长度)
  • pmd:UseVarargs(使用Varargs)
  • squid:S2208(不应使用通配符导入)

现在我得到一个ArrayOutOfBoundsException:

[DEBUG] [16:25:04.971] Decorators: ManualMeasureDecorator -> QProfileEventsDecorator -> org.sonar.batch.design.ProjectDsmDecorator@f11bc3 -> org.sonar.batch.design.SubProjectDsmDecorator@155b434 -> org.sonar.batch.design.DirectoryDsmDecorator@1a9fa00 -> FileTangleIndexDecorator -> SumDuplicationsDecorator -> UnitTestDecorator -> org.sonar.plugins.core.security.ApplyProjectRolesDecorator@81db67 -> org.sonar.plugins.core.sensors.DirectoriesDecorator@567bc5 -> org.sonar.plugins.core.sensors.FilesDecorator@1d7c3b5 -> org.sonar.plugins.core.timemachine.TimeMachineConfigurationPersister@6da7af -> org.sonar.plugins.core.timemachine.NewCoverageFileAnalyzer@71df98 -> org.sonar.plugins.core.timemachine.NewItCoverageFileAnalyzer@e7d9d -> org.sonar.plugins.core.timemachine.NewOverallCoverageFileAnalyzer@15908eb -> org.sonar.plugins.core.timemachine.NewCoverageAggregator@588740 -> f(lines) -> f(generated_lines) -> f(ncloc) -> f(generated_ncloc) -> f(classes) -> f(packages) -> f(functions) -> f(accessors) -> f(statements) -> f(public_api) -> f(comment_lines) -> f(public_undocumented_api) -> f(commented_out_code_lines) -> f(complexity) -> f(complexity_in_classes) -> f(complexity_in_functions) -> f(class_complexity_distribution) -> f(function_complexity_distribution) -> f(file_complexity_distribution) -> f(lines_to_cover) -> f(uncovered_lines) -> f(conditions_to_cover) -> f(uncovered_conditions) -> f(it_lines_to_cover) -> f(it_uncovered_lines) -> f(it_conditions_to_cover) -> f(it_uncovered_conditions) -> f(overall_lines_to_cover) -> f(overall_uncovered_lines) -> f(overall_conditions_to_cover) -> f(overall_uncovered_conditions) -> f(rfc) -> f(rfc_distribution) -> f(lcom4_distribution) -> f(package_cycles) -> f(package_tangles) -> f(package_feedback_edges) -> f(package_edges_weight) -> f(new_lines_to_cover) -> f(new_uncovered_lines) -> f(new_conditions_to_cover) -> f(new_uncovered_conditions) -> f(new_it_lines_to_cover) -> f(new_it_uncovered_lines) -> f(new_it_conditions_to_cover) -> f(new_it_uncovered_conditions) -> f(new_overall_lines_to_cover) -> f(new_overall_uncovered_lines) -> f(new_overall_conditions_to_cover) -> f(new_overall_uncovered_conditions) -> org.sonar.batch.language.LanguageDistributionDecorator@16cc1dd -> DirectoryTangleIndexDecorator -> org.sonar.batch.cpd.decorators.DuplicationDensityDecorator@1aaebaf -> CommentDensityDecorator -> f(file_complexity) -> f(class_complexity) -> f(function_complexity) -> org.sonar.plugins.core.sensors.LineCoverageDecorator@deec30 -> org.sonar.plugins.core.sensors.CoverageDecorator@1648255 -> org.sonar.plugins.core.sensors.BranchCoverageDecorator@1a8bbfd -> org.sonar.plugins.core.sensors.ItLineCoverageDecorator@cdf676 -> org.sonar.plugins.core.sensors.ItCoverageDecorator@1efcdcd -> org.sonar.plugins.core.sensors.ItBranchCoverageDecorator@b06757 -> org.sonar.plugins.core.sensors.OverallLineCoverageDecorator@150bda1 -> org.sonar.plugins.core.sensors.OverallCoverageDecorator@1d1b166 -> org.sonar.plugins.core.sensors.OverallBranchCoverageDecorator@1d5aaba -> Common Rules for java -> org.sonar.batch.issue.tracking.IssueTrackingDecorator@94dc01 -> org.sonar.batch.debt.DebtDecorator@12bcb44 -> org.sonar.batch.debt.NewDebtDecorator@2df694 -> CountUnresolvedIssuesDecorator -> CountFalsePositivesDecorator -> org.sonar.batch.debt.SqaleRatingDecorator@1978848 -> org.sonar.plugins.core.timemachine.TendencyDecorator@18aadb2 -> VariationDecorator -> QualityGateVerifier -> org.sonar.batch.qualitygate.GenerateQualityGateEvents@177f07
[DEBUG] [16:25:05.049] Release semaphore on project : org.sonar.api.resources.Project@11a5ab8[id=955,key=xxxxxxxxx:XXXXXXXXXXX,qualifier=TRK], with key batch-xxxxxxxxx:XXXXXXXXXXX
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] XXXXXXXXXXX ....................................... FAILURE [06:55 min]
[INFO] XXXXXXXXX ......................................... SKIPPED
[INFO] XXXXXXXXX ......................................... SKIPPED
[INFO] XXXXXXXX .......................................... SKIPPED
[INFO] XXXXXXXXXXXXX ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:56 min
[INFO] Finished at: 2016-05-12T16:25:05+01:00
[INFO] Final Memory: 52M/247M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project XXXXXXXXXXX: Fail to decorate 'org.sonar.api.resources.File@18260be[key=src/main/java/xxxxxxxxx/model/BaseEntity.java,path=src/main/java/xxxxxxxxx/BaseEntity.java,filename=BaseEntity.java,language=Java]': 163 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project XXXXXXXXXXX: Fail to decorate 'org.sonar.api.resources.File@18260be[key=src/main/java/xxxxxxxxx/model/BaseEntity.java,path=src/main/java/xxxxxxxxx/model/BaseEntity.java,filename=BaseEntity.java,language=Java]'
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fail to decorate 'org.sonar.api.resources.File@18260be[key=src/main/java/xxxxxxxxx/model/BaseEntity.java,path=src/main/java/xxxxxxxxx/model/BaseEntity.java,filename=BaseEntity.java,language=Java]'
    at org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:41)
    at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:139)
    at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:138)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: org.sonar.api.utils.SonarException: Fail to decorate 'org.sonar.api.resources.File@18260be[key=src/main/java/xxxxxxxxx/model/BaseEntity.java,path=src/main/java/xxxxxxxxx/model/BaseEntity.java,filename=BaseEntity.java,language=Java]'
    at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:104)
    at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:87)
    at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
    at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
    at org.sonar.batch.phases.DecoratorsExecutor.execute(DecoratorsExecutor.java:71)
    at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:127)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:135)
    ... 22 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 163
    at org.sonar.batch.issue.tracking.FileHashes.getHash(FileHashes.java:89)
    at org.sonar.batch.issue.tracking.IssueTracking.setChecksumOnNewIssues(IssueTracking.java:66)
    at org.sonar.batch.issue.tracking.IssueTracking.track(IssueTracking.java:51)
    at org.sonar.batch.issue.tracking.IssueTrackingDecorator.doDecorate(IssueTrackingDecorator.java:139)
    at org.sonar.batch.issue.tracking.IssueTrackingDecorator.decorate(IssueTrackingDecorator.java:113)
    at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:96)
    ... 57 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Build step 'Maven Goals aufrufen' marked build as failure
Finished: FAILURE

任何人都知道我如何找到导致问题的规则,而无需亲自尝试每个规则?

修改 我确定了导致我的问题的规则(我不知道为什么或者这是否是特定于项目的):

  • fb-contrib:UCPM_USE_CHARACTER_PARAMETERIZED_METHOD(性能 - 方法将长度为1的常量字符串传递给字符重写方法)
  • fb-contrib:COM_COPIED_OVERRIDDEN_METHOD(样式 - 方法是使用其超类的方法的精确副本实现的)

0 个答案:

没有答案