软件构造第五次学习博客——SpotBugs概述
SpotBugs 介绍
SpotBugs是Findbugs的继任者(用于对代码进行静态分析,查找相关的漏洞。
SpotBugs官方文档的bug描述
目前SpotBugs 自带检测器,其中有90余种Bad practice,155余种Correctness,9种Experimental, 2种 Internationalization,17种Malicious code vulnerability,46种Multithreaded correctness,4种 Bogus random noise,37种Performance,11种 Security,87种Dodgy。

Malicious code vulnerability (MALICIOUS_CODE)恶意代码漏洞
code that is vulnerable to attacks from untrusted code
代码有漏洞,可能被攻击

Multithreaded correctness (MT_CORRECTNESS)多线程的正确性
code flaws having to do with threads, locks, and volatiles
可能导致线程、死锁及不稳定的

Performance (PERFORMANCE)性能
code that is not necessarily incorrect but may be inefficient
可能代码正确但是性能会有问题的地方

Security (SECURITY)安全
A use of untrusted input in a way that could create a remotely exploitable security vulnerability.
非安全输入,可导致远程利用的安全漏洞

Bad practice (BAD_PRACTICE)低劣的代码实践,违反推荐和必要的编码惯例
Violations of recommended and essential coding practice. Examples include hash code and equals problems, cloneable idiom, dropped exceptions, Serializable problems, and misuse of finalize.

Correctness (CORRECTNESS)正确性,可能出现非预期的代码错误
Probable bug - an apparent coding mistake resulting in code that was probably not what the developer intended.

Experimental (EXPERIMENTAL)实验性的
Experimental and not fully vetted bug patterns

Dodgy code (STYLE)糟糕的代码(风格)
code that is confusing, anomalous, or written in a way that leads itself to errors. Examples include dead local stores, switch fall through, unconfirmed casts, and redundant null check of value known to be null. More false positives accepted.

Internationalization (I18N)国际化
code flaws having to do with internationalization and locale

Bogus random noise (NOISE)假的随机噪音
Bogus random noise: intended to be useful as a control in data mining experiments, not in finding actual bugs in software

Bad practice 不佳实践:常见代码错误,用于静态代码检查时进行缺陷
模式匹配(如重写equals但没重写hashCode,或相反情况等)
Correctness 可能导致错误的代码(如空指针引用、无限循环等)
Experimental 实验性
Internationalization 国际化相关问题(如错误的字符串转换等)
Malicious code vulnerability 可能受到的恶意攻击(如访问权限修饰符的定义等)
Multithreaded correctness 多线程的正确性(如多线程编程时常见的同步,线程调度问题等)
BogusMultithreaded correctness 多线程的正确性(如多线程编程时常见的同步,线程调度问题等)
Performance 运行时性能问题(如由变量定义,方法调用导致的代码低效问题等)
Security 安全问题(如HTTP,SQL,DB等)
Dodgy code 导致自身错误的代码(如未确认的强制转换、冗余的空值检查等)
注: SpotBugs 需要当前的JDK环境为 1.8以上,但可以对1.0~1.9的代码来进行检查。

SpotBugs 插件
SpotBugs 还有对应的额外插件,用于扩展对应的规则,探测出更多的代码问题。

SpotBugs 使用
Maven
maven 插件方式使用 spotbugs及相关插件


<plugin><groupId>com.github.spotbugs</groupId><artifactId>spotbugs-maven-plugin</artifactId><version>3.1.1</version><configuration><plugins><plugin><groupId>com.h3xstream.findsecbugs</groupId><artifactId>findsecbugs-plugin</artifactId><version>LATEST</version></plugin><plugin><groupId>com.mebigfatguy.fb-contrib</groupId><artifactId>fb-contrib</artifactId><version>7.4.3.sb</version></plugin></plugins></configuration>
</plugin>

IDE环境
Eclipse
请在对应的marketplace 搜索或install new software来进行spotbugs的安装,正式版本的安装路径 https://spotbugs.github.io/eclipse/

安装插件后,可以在对应的Preferences 进行更多SpotBugs plugin安装,参考如下图:

可以通过以下网址获取最新的插件jar
https://mvnrepository.com/artifact/com.mebigfatguy.fb-contrib/fb-contrib
https://mvnrepository.com/artifact/com.h3xstream.findsecbugs/findsecbugs-plugin
完成安装后,可以对java工程或者对应的类,右键进行 SpotBugs ->Find Bugs

JetBrain IDEA
目前没有SpotBugs插件,原FindBugs插件作者、IDEA还在讨论商标问题,请先使用 原有FindBugs代替。
https://github.com/andrepdo/findbugs-idea/issues/265
https://youtrack.jetbrains.com/issue/IDEA-201846

其他更多内容可以参考SpotBugs 官方文档
https://spotbugs.readthedocs.io/en/latest/installing.html

软件构造第五次学习博客——SpotBugs概述相关推荐

  1. 第五周学习博客(CSS)

    目录 1.CSS简介 1.2 1.3CSS语法规范 1.4CSS代码风格 格式:展开格式 2.CSS基础选择器 2.2选择器分类 2.3标签选择器 2.4类选择器(使用较多) 1.多类名使用方式 2. ...

  2. 第十五次ScrumMeeting博客

    第十五次ScrumMeeting博客 本次会议于12月4日(一)22时整在3公寓725房间召开,持续30分钟. 与会人员:刘畅.辛德泰.张安澜.赵奕.方科栋. 1. 每个人的工作(有Issue的内容和 ...

  3. 记录自己第一个java学习博客

    记录自己第一个java学习博客 阿里java规范 弄懂 JRE.JDK.JVM 之间的区别与联系 DOS常用命令 常用mac终端命令 今天我学习了java第一个程序打印出helloworld! pac ...

  4. JAVA学习博客---2015.5

    上一次的学习博客写的和流水账差不多,有点生硬的和背目录一样,所以既然学习的目的是程序,那么这个月的学习博客就用程序来说点东西吧.这个月看了一些C和JAVA的视频,开始看别人写的程序,能看的懂但是自己去 ...

  5. 几个非常有用的iOS学习博客链接

    几个非常有用的iOS学习博客链接 请仔细阅读相关链接下的其他博客的文章: http://blog.csdn.net/sanpintian/article/details/7402853 http:// ...

  6. 【Javascript基础语法】第五周预习博客

    Javascript基础语法 前言 一.初识JavaScript 1.JS是什么 2.作用 3.浏览器执行js简介 4.Js组成 二.JS的引入方式 1.行内式 2.内部引入 3.外部引入 三.js语 ...

  7. 多亏了这几款软件,我才能坚持写博客这么多年!

    点击关注上方"五分钟学算法", 设为"置顶或星标",第一时间送达干货. 写博客大致可以分为三步: 写作前 写作中 写作后 按照这三步介绍这个过程中我用到一些工具 ...

  8. 转载一个不错的Scrapy学习博客笔记

    背景: 最近在学习网络爬虫Scrapy,官网是 http://scrapy.org 官方描述:Scrapy is a fast high-level screen scraping and web c ...

  9. Android学习博客和文章存档

    [Android基础]Android总结篇 http://blog.csdn.net/codeemperor/article/details/51004189 Android最佳性能实践(一)--合理 ...

最新文章

  1. [黑金原创教程] FPGA那些事儿《数学篇》- CORDIC 算法
  2. vs--bookmark用法
  3. LaTex 更改文字颜色
  4. Could not parse configuration: /hibernate.cfg.xml
  5. PHP实现10亿个商品编码ing
  6. Centos7设置Tomat开机自启
  7. 用python画桃花_python 画图
  8. pytorch4:简单的线性回归
  9. c#中的委托、事件、Func、Predicate、Observer设计模式以及其他
  10. python颜色表_Python:数据可视化,必须注意的30个小技巧
  11. 11款超5000星 后台管理模板, 总有一款适合你!
  12. CDH运维常见问题-cloudera-scm-agent 已死,但 pid 文件存在
  13. cfar matlab,雷达无线电系列(二)经典CFAR算法图文解析与实现(matlab)
  14. 软件人才应具备的五种素质
  15. 服务器和客户端信息的获取
  16. 台式计算机怎么加声音,台式电脑音量加到最大还是没有声音怎么办,教你一招立马解决...
  17. TB,GB,MB,KB,Byte字节,bit位 如何换算?
  18. [转]Mac 科研常用软件
  19. JAVA实现链接生成二维码
  20. 【大数据】为什么要学习大数据

热门文章

  1. 使用mxGraph绘制流程图
  2. 如何写毕业论文降低查重率?
  3. 关于速营社,我也是偶遇
  4. OMP: Error #15的解决办法:
  5. mysql中timeStamp转成yyyy-MM-dd hh:mm
  6. 《MATLAB智能算法30个案例》:第25章 有导师学习神经网络的回归拟合——基于近红外光谱的汽油辛烷值预测
  7. 简明入门讲义——DNS架构是如何发展的
  8. Linux通过修改date命令,验证shadow的密码有效期,提示期和宽限期
  9. 男人30岁前要完成的事
  10. GoLang封装常用工具方法