findbugs

Is SonarQube Replacement for Checkstyle, PMD, FindBugs?

独自空忆成欢 提交于 2019-12-02 13:54:12
We are working on a web project from scratch and are looking at the following static code analysis tools. Conventions (Checkstyle) Bad practices (PMD) Potential bugs (FindBugs) The project is built on Maven. Instead of using multiple tools for the purpose, I was looking at a single flexible solution and came across SonarQube. Is it true that we can achieve the results from Checkstyle, PMD and Findbugs with SonarQube? Sonar will run CheckStyle, FindBugs and PMD, as well as a few other "plugins" such as Cobertura (code coverage) by default for Java projects. The main added value, however, is

在Eclipse或MyEclipse中安装findbugs插件

喜夏-厌秋 提交于 2019-12-02 04:54:59
在Eclipse或MyEclipse中安装findbugs插件 我们都知道,在Eclipse或MyEclipse(我用的8.0)中安装插件有两种方式,一种是在线安装,第二种是先下载插件然后在本地安装。 在这里我们先介绍第一种在线安装。 Eclipse上在线安装findbugs(具体步骤如下,就不再赘述) In Eclipse, click on Help -> Software Update -> Find and Install... Choose the Search for new features to install option, and click Next . Click New Remote Site . Enter the following: Name: FindBugs update site URL: one of the following (note: no final slash on the url) http://findbugs.cs.umd.edu/eclipse for official releases http://findbugs.cs.umd.edu/eclipse-candidate for candidate releases and official releases http://findbugs.cs.umd.edu

FindBugs wants readObject(…) to be private for serialization, why?

妖精的绣舞 提交于 2019-12-01 22:43:16
I am running findbugs on some code and it says the readObject(...) method must be private to be invoked for serialization/unserialization? Why? What is the problem if it is made public? About readObject()/writeObject() being private, here's the deal: if your class Bar extends some class Foo; Foo also implements readObject()/writeObject() and Bar also implements readObject()/writeObject() . Now, when a Bar object is serialized or deserialized, JVM needs to call readObject()/writeObject() for both Foo and Bar automatically (i.e. without you needing to call these super class methods explicitly).

Findbugs issue with ant

心不动则不痛 提交于 2019-12-01 22:15:11
findbugs: [findbugs] Executing findbugs from ant task [findbugs] Running FindBugs... [findbugs] java.lang.NoClassDefFoundError: org/apache/bcel/classfile/ClassFormtException [findbugs] Caused by: java.lang.ClassNotFoundException: org.apache.bcel.classfile.ClassFormatException [findbugs] at java.net.URLClassLoader$1.run(URLClassLoader.java:202) [findbugs] at java.security.AccessController.doPrivileged(Native Method) [findbugs] at java.net.URLClassLoader.findClass(URLClassLoader.java:190) [findbugs] at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [findbugs] at sun.misc.Launcher

How to write a customized gradle task to not to ignore Findbugs violations but fail after the analysis is completed

非 Y 不嫁゛ 提交于 2019-12-01 20:02:21
I want to write such a gradle task (using the Findbugs plugin) which fails if any Findbugs violations are found but only after completing the analysis . If I do ignoreFailures=true the task won't fail at all and if I make it false the task fails as soon as the first issue is found. I want the task to perform a complete analysis and fail only after it's done if any violations are found. You're right, adding ignoreFailures=true will prevent task from failing. Thus this option should be used and it should be checked later on if bugs were found. This script does the job: apply plugin: 'java' apply

Suppressing Java Findbugs error (EI_EXPOSE_REP)

有些话、适合烂在心里 提交于 2019-12-01 17:04:22
I have a Java gettor method that looks like the following: import java.util.Date; //... public Date getSomeDate() { return someDate; } and Findbugs reports that this exposes a mutable object: "May expose internal representation by returning reference to mutable object". I changed the code to this: import java.util.Date; //... public Date getSomeDate() { return new Date(someDate.getTime()); } but Findbug still reports the same vulnerability. What more can I do to suppress/fix this problem? I am running Findbugs 1.3.9 in the IntellJ 10 Findbugs plugin. I just realized that Findbugs analyzes

Suppressing Java Findbugs error (EI_EXPOSE_REP)

感情迁移 提交于 2019-12-01 16:49:40
问题 I have a Java gettor method that looks like the following: import java.util.Date; //... public Date getSomeDate() { return someDate; } and Findbugs reports that this exposes a mutable object: "May expose internal representation by returning reference to mutable object". I changed the code to this: import java.util.Date; //... public Date getSomeDate() { return new Date(someDate.getTime()); } but Findbug still reports the same vulnerability. What more can I do to suppress/fix this problem? I

Findbugs插件使用

蓝咒 提交于 2019-12-01 14:33:25
findbugs简介 Findbugs 是一个Java代码静态分析工具,可以用它来检查源代码中可能出现的问题,以期尽可能在项目的初始阶段将代码问题解决。 FindBugs检查的是类或者JAR文件即字节代码(*.class),将字节码与一组缺陷模式进行对比以发现可能的问题;许多我们写的不好的可以优化的地方,它都能检查出来并给建议,比如未关闭的数据库连接、缺少必要的null check、多余的 null check、多余的if后置条件、重复的代码块、错误的使用了"==",建议使用StringBuffer代替字符串连加等等。而且我们还可以自己配置检查规则,也可以自己来实现findbugs的接口,以便独有的校验规则。 下载findbugs 点击这里 到最新版本的findbugs下载页面,我下载的是" findbugs-3.0.0-rc1.tar.gz ",(windows下使用)解压后运行bin\findbugs.bat,即可看到如下界面: 可以通过“文件”->"新建": 分别选择“要分析的类包和目录”、”辅助类的位置“、“源文件目录”,然后“Analyze”: 我们更常用的方式是使用它的eclipse插件,因为这种方式手动选择类和源文件以及辅助类,都是比较麻烦的事。 在eclipse使用findbugs插件 可以使用下面的地址安装findbugs插件: http://findbugs

Reusing a PreparedStatement

我与影子孤独终老i 提交于 2019-12-01 08:35:19
I ran findbugs on our code base and it pointed out there are two more Statements that still need to be closed. In this section of the code we run: preparedStatement = connection.prepareStatement(query); for 3 different queries, reusing preparedStatement. In the finally block we do close the resource: finally{ try{ if (resultSet != null) resultSet.close(); } catch (Exception e) { exceptionHandler.ignore(e); } try { if (preparedStatement != null) preparedStatement.close(); } catch(Exception e) { exceptionHandler.ignore(e); } Should the statement be closed before the next connection

Security - Array is stored directly

随声附和 提交于 2019-12-01 06:16:49
I even refered : Sonar Violation: Security - Array is stored directly My code is as ---> public final void setSelectedObjectsList(final ScheduleDTO[] selectedObjectsList) // Security - Array is stored directly //The user-supplied array 'selectedObjectsList' is stored directly. { if (selectedObjectsList != null) { this.selectedObjectsList = selectedObjectsList.clone(); } else { this.selectedObjectsList = null; } } This is already taking care of defensive copy wonder why sonar is yelling at me right at function parameter. This not not duplicate as Sonar Violation: Security - Array is stored