1、代码里面包含PASSWORD、PWD

'PWD' detected in this expression, review this potentially hardcoded credential.

2、父子类或者同一个类有同名的变量名(类方法、类变量、实例方法或者实例变量)

Rename method "ENCRYPTMethod" to prevent any misunderstanding/clash with method "encryptMethod" defined on line 35.
public static String encryptMethod(String HexString, String keyStr) {
....
} public static String ENCRYPTMethod(String HexString, String keyStr, String keyENCODED, String HexStringENCODED, String CipherInstanceType) throws Exception {
.....
}

或者

比如父类定义了一个Logger logger=...的logger变量,

子类又再次定义logger变量

父类里面已存在

或者

实体类的get/set方法多次定义,仅仅大小写不一样

同一个类里面

3、涉及到资源关闭这种,Use try-with-resources or close this "BufferedOutputStream" in a "finally" clause.

Use try-with-resources or close this "BufferedOutputStream" in a "finally" clause.

这种比较麻烦,传统的做法,即在finally里面进行if(stream!=null)(try{}catch(){})关闭仍然无法通过

这种单独开一篇博客寻找解决方法,见下一篇博客

Resources should be closed (squid:S2095)
Bug Blocker
Connections, streams, files, and other classes that implement the Closeable interface or its super-interface, AutoCloseable, needs to be closed after use. Further, that close call must be made in a finally block otherwise an exception could keep the call from being made. Preferably, when class implements AutoCloseable, resource should be created using "try-with-resources" pattern and will be closed automatically. Failure to properly close resources will result in a resource leak which could bring first the application and then perhaps the box it's on to their knees. Noncompliant Code Example
private void readTheFile() throws IOException {
Path path = Paths.get(this.fileName);
BufferedReader reader = Files.newBufferedReader(path, this.charset);
// ...
reader.close(); // Noncompliant
// ...
Files.lines("input.txt").forEach(System.out::println); // Noncompliant: The stream needs to be closed
} private void doSomething() {
OutputStream stream = null;
try {
for (String property : propertyList) {
stream = new FileOutputStream("myfile.txt"); // Noncompliant
// ...
}
} catch (Exception e) {
// ...
} finally {
stream.close(); // Multiple streams were opened. Only the last is closed.
}
}
Compliant Solution
private void readTheFile(String fileName) throws IOException {
Path path = Paths.get(fileName);
try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
reader.readLine();
// ...
}
// ..
try (Stream<String> input = Files.lines("input.txt")) {
input.forEach(System.out::println);
}
} private void doSomething() {
OutputStream stream = null;
try {
stream = new FileOutputStream("myfile.txt");
for (String property : propertyList) {
// ...
}
} catch (Exception e) {
// ...
} finally {
stream.close();
}
}
Exceptions
Instances of the following classes are ignored by this rule because close has no effect: •java.io.ByteArrayOutputStream
•java.io.ByteArrayInputStream
•java.io.CharArrayReader
•java.io.CharArrayWriter
•java.io.StringReader
•java.io.StringWriter
Java 7 introduced the try-with-resources statement, which implicitly closes Closeables. All resources opened in a try-with-resources statement are ignored by this rule. try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
//...
}
catch ( ... ) {
//...
}
See
•MITRE, CWE-459 - Incomplete Cleanup
•CERT, FIO04-J. - Release resources when they are no longer needed
•CERT, FIO42-C. - Close files when they are no longer needed
•Try With Resources

sonar阻断级别错误(block)简单汇总的更多相关文章

  1. atitit.404错误调查过程汇总

    atitit.404错误调查过程汇总 #----------jsp  head  errorPage="" del zeu ok le. #------resin server. ...

  2. win服务器 文件上传下载出现“未指定的错误” 解决方法汇总

    环境 WIN平台IIS服务器   经常出现于ASPX页面 汇总 1.权限问题 出现场景 : 基于ACCESS数据库   原因解析 : 1.首先需要排除自身问题,例如建表使用关键字,格式错误,插入数据与 ...

  3. (转)Linux下root密码丢失和运行级别错误的解决办法

    我们知道,root用户在Linux中是相当重要的,其地位如同Windows中的Adminstrator 有了root权限我们还能修改其他用户的密码,可是,如果root用户的密码丢失该怎么办? 不用担心 ...

  4. Linux内存简单汇总

    Linux内存主要用来存储系统和应用程序的指令,数据,缓存等 一,内存映射 1,内核给每个进程提供一个独立的虚拟机地址空间,并且这个地址空间是连续的 2,虚拟地址空间内部又被分为内核空间和用户空间 3 ...

  5. Python中对时间日期的处理方法简单汇总

    这篇文章主要介绍了Python实用日期时间处理方法汇总,本文讲解了获取当前datetime.获取当天date.获取明天/前N天.获取当天开始和结束时间(00:00:00 23:59:59).获取两个d ...

  6. iOS常用设计模式和机制之Block简单使用

    Block :block 实际上就是 Objective-C语言对闭包的实现 闭包(Closure):闭包就是一个函数,或者一个指向函数的指针,加上这个函数执行的非局部变量.闭包允许一个函数访问声明该 ...

  7. 【转】20个Cydia常见错误问题解决方法汇总

    对于已经越狱的用户来说,经常会使用Cydia来安装一些酷炫或实用插件,但是有时候它总是会出现一些问题,以下收集了在Cydia经常遇到的问题,供大家参考: 一.主屏幕没有 Cydia 图标 1.设备需已 ...

  8. Xcode编译错误和警告汇总<转>

    1.error: macro names must be identifiers YourProject_prefix.pch 原因: 因为你弄脏了预处理器宏,在它处于<Multiple Val ...

  9. iOS block简单传值

    (1)声明block变量并设置返回值类型 typedef int(^MYBlock)(NSString *); @property (nonatomic, copy) MYBlock block; ( ...

随机推荐

  1. Python实现阿里云短信推送

    本篇文章是使用Python的Web框架Django提供发送短信接口供前端调用,Python版本2.7 阿里云入驻.申请短信服务.创建应用和模板等步骤请参考:阿里云短信服务入门 1.下载sdk 阿里云短 ...

  2. Linux实战教学笔记19:Linux相关网络知识梳理

    第十九节 Linux相关网络知识梳理 标签(空格分隔): Linux实战教学笔记-陈思齐 一,前言 一个运维有时也要和网络打交道,所以具备最基本的网络知识,对一个运维人员来说是必要的.但,对于我们的工 ...

  3. EMC存储同时分配空间到两台服务器路径不一致-双机盘符不一致

    以下方式将i盘盘符换成g盘,g盘盘符换成i emcpadm rename -s emcpoweri -t emcpowerj emcpadm rename -s emcpowerg -t emcpow ...

  4. 32. Longest Valid Parentheses (Stack; DP)

    Given a string containing just the characters '(' and ')', find the length of the longest valid (wel ...

  5. Hibernate事务代码规范写法

    ----------------siwuxie095 事务相关概念 1.什么是事务 逻辑上的一组操作,构成这组操作的各个单元,要么一起成功, 要么一起失败 2.事务的四个特性 1)原子性 2)一致性 ...

  6. XHTML的规范化

    -------------------siwuxie095                                 XHTML 简介         1.什么是 XHTML?     XHTM ...

  7. android-tip-SocketException之ETIMEDOUT

    异常出现时间 如果我们有一个长连接,此时网络被关闭,或者暂时失去信号, 此时就会出现此异常. 如果出现此异常,则不得不重连.

  8. 浅谈Java中set.map.List的区别

    就学习经验,浅谈Java中的Set,List,Map的区别,对JAVA的集合的理解是想对于数组: 数组是大小固定的,并且同一个数组只能存放类型一样的数据(基本类型/引用类型),JAVA集合可以存储和操 ...

  9. Zedboard学习(二):zedboard的Linux下交叉编译环境搭建 标签: 交叉编译linuxzedboard 2017-07-04 23:49 19人阅读

    环境准备 首先肯定是要下载xilinx-2011.09-50-arm-xilinx-linux-gnueabi.bin文件,这是官方提供的linux下交叉编译链安装文件,下载地址为:https://p ...

  10. scp 的时候提示WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

    摘自:https://blog.csdn.net/haokele/article/details/72824847   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ...