findbugs

how can resolve dodgy:unchecked/unconfirmed cast in sonar?

别来无恙 提交于 2019-12-24 06:27:57
问题 iam getting the exception through sonar in this following code.How can I resolve this.Suggest me. @Override public boolean validate(BaseInfo infoObject) { boolean isValid = true; AckTransferPaymentInfo ackTransferPaymentInfo = (AckTransferPaymentInfo) infoObject; Dodgy - Unchecked/unconfirmed cast Unchecked/unconfirmed cast from com.vocalink.acsw.common.validation.info.BaseInfo to com.vocalink.acsw.common.validation.info.AckTransferPaymentInfo in com.vocalink.acsw.validation.rule.T170Rule

How to use findbugs @Nonnull with external libraries?

我的梦境 提交于 2019-12-24 04:02:15
问题 I started using findbugs @Nonnull and @CheckForNull annotations on an existing Project, to prevent NPEs, and think it works quite nice. I use @Nonnull as default for return types and parameters and found already a few NPEs, just by adding the default values. Now I found a method similar to this: @Nonnull private Integer getInteger(String key) { return Map.get(key); } And it does not produce a warning. I understand why this is the case, but how can I get around this? How do you work around

Maven sonar plugin configurations for findbugs pmd checkstyle cobertura

╄→гoц情女王★ 提交于 2019-12-23 18:24:20
问题 I need some help in setting up code quality plugin for maven project. I have a multi module project. While I have configured pmd , checkstyle , findbugs and cobertura in my build process, and I can generate xml reports for each plugin, I am facing some challenges configuring the sonar plugin in my project. I am not sure how to approach this problem: Should I reuse the reports generated by these plugins while executing sonar? if so what should my sonar plugin configuration be? If I run sonar

Findbug - ANT xslt stylesheet source code references

喜欢而已 提交于 2019-12-23 16:28:21
问题 I have an ANT target that runs findbugs twice on the same source code to generate a xml and html report <delete dir="${findbugs.dir}"/> <mkdir dir="${findbugs.dir}"/> <findbugs home="${findbugs.home}" output="xml" outputFile="${findbugs.dir}/findbugs.xml" jvmargs="${findbugs.jvmargs}" timeout="${findbugs.timeout}" effort="${findbugs.effort}"> <sourcePath path="${src.dir}"/> <class location="${build.classes.dir}"/> </findbugs> <findbugs home="${findbugs.home}" output="html" outputFile="$

force IntelliJ to fail the compilation on NonNull violations

做~自己de王妃 提交于 2019-12-23 13:16:46
问题 I have the simple code below for testing the NonNull annotations in IntelliJ. Then I go to: IntelliJ -> File -> Settings -> Inspections -> Probable bugs -> Constant conditions & exceptions and I set-up Severity: As error. Doing so, it marks the line "print(null);" as an error as expected. However, executing IntelliJ -> Build -> Rebuild project, it works and it does not show any error and it does not show any warning. Why is so? Why IntelliJ does not complain when building the project? How to

force IntelliJ to fail the compilation on NonNull violations

为君一笑 提交于 2019-12-23 13:16:02
问题 I have the simple code below for testing the NonNull annotations in IntelliJ. Then I go to: IntelliJ -> File -> Settings -> Inspections -> Probable bugs -> Constant conditions & exceptions and I set-up Severity: As error. Doing so, it marks the line "print(null);" as an error as expected. However, executing IntelliJ -> Build -> Rebuild project, it works and it does not show any error and it does not show any warning. Why is so? Why IntelliJ does not complain when building the project? How to

Import FindBugs configuration from Sonar to Maven

不羁岁月 提交于 2019-12-23 09:30:36
问题 How can I use a FindBugs configuration file from Sonar as the rule set in the Maven FindBugs plugin? 回答1: You can place your file, i.e. findbugs-sonar.xml in the src/main/resource folder and specify the path in your maven reporting settings like this: <reporting> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> <version>2.5.3-SNAPSHOT</version> <configuration> <includeFilterFile>findbugs-sonar.xml</includeFilterFile> </configuration> <

配置sonar和jenkins进行代码审查

柔情痞子 提交于 2019-12-23 06:31:07
转自: http://www.cnblogs.com/gao241/p/3190701.html, 版权归原作者所有。 本文以CentOS操作系统为例介绍Sonar的安装配置,以及如何与Jenkins进行集成,通过pmd-cpd、checkstyle、findbugs等工具对代码进行持续审查。 一、安装配置sonar 1、Sonar介绍 Sonar是一个用于代码质量管理的开源平台,用于管理Java源代码的质量。通过插件机制,Sonar 可以集成不同的测试工具,代码分析工具,以及持续集成工具,比如pmd-cpd、checkstyle、findbugs、Jenkins。通过不同的插件对这些结果进行再加工处理,通过量化的方式度量代码质量的变化,从而可以方便地对不同规模和种类的工程进行代码质量管理。 同时 Sonar 还对大量的持续集成工具提供了接口支持,可以很方便地在持续集成中使用 Sonar。 此外,Sonar 的插件还可以对 Java 以外的其他编程语言提供支持,对国际化以及报告文档化也有良好的支持。 2、配置数据库 Apache Derby 是Sonar自带并且默认安装使用的数据库,此外Sonar对如下数据库提供支持:MySQL 5.x, Oracle 10g XE, Postgresql, MS SqlServer等,本文以mysql为例介绍如何配置数据库: 1)创建数据库

Suppress FindBugs warnings in Eclipse

爱⌒轻易说出口 提交于 2019-12-22 10:49:07
问题 I am using a string as a lock and so want to ensure the object is a new instance. FindBugs complains because it's generally more efficient to define the string directly (with double quotes). My code looks like: /** A lock for the list of inputs. */ @edu.umd.cs.findbugs.annotations.SuppressWarnings("DM_STRING_CTOR") //We want a new String object here as this is a lock. private final Object inputListLock = new String("inputListLock"); Am I doing something wrong here? The Eclipse FindBugs plugin

how to deal with bug “dead store to local variable” in java?

醉酒当歌 提交于 2019-12-22 10:46:45
问题 I wrote a simple test code. It is a circle. I suppose most people can image what is a circle class, so I will not paste it. In the test code, I try to test the circle constructor with invalid point, and assume to throw an exception. But a bug occures. I check online, but still do not know how to solve the problem. Is there any one can help me? Thanks code information, bug is in the last sentence of following code /** * Tests that the Circle constructor throws an exception for center Point. */