Showing 349 of 349 total issues
Method findDiffIndexPoint
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static int findDiffIndexPoint(String a, String b) {
if (StringUtils.equals(a, b)) {
return 0;
}
if (Objects.isNull(a)) {
Method savedAll
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void savedAll() {
BufferedWriter bw = null;
OutputStream out = null;
OutputStreamWriter os = null;
Method ablePass
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static boolean ablePass(Tank t, Hinder h) {
int hx = h.getWidth(), hy = h.getHeight();
final int halfHeight = t.getHalfHeight();
final int halfWidth = t.getHalfWidth();
Method saveDataBase
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void saveDataBase() {
PreparedStatement ps = null;
Connection cn = null;
ResultSet rs = null;
Method findDiffIndex
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static int findDiffIndex(String a, String b) {
if (StringUtils.equals(a, b)) {
return 0;
}
if (Objects.isNull(a)) {
Method sortData
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void sortData(int[] data, int low, int high) {
int lowIndex = low;
int highIndex = high;
int index = data[low];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method paintComponent
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
@Override
protected void paintComponent(Graphics g) {
int offset = 4;
int r = 5;
int chessR = 20;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method start
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public void start() throws IOException {
Selector selector = Selector.open();
//通过OPEN方法来打开一个未绑定的ServerSocketChannel 实例
ServerSocketChannel server = ServerSocketChannel.open();
//将该ServerSocketChannel绑定到指定ip
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method showRows
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private void showRows() {
StringBuilder MaxRows = new StringBuilder("Max(z)=");
for (int i = 0; i < MAX_PARAMS; i++) {
if (!Max.get(i).isZero()) {
MaxRows.append(Max.get(i)).append(" X").append(i + 1).append(" + ");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void run() throws Exception {
init();
//运算出初始的表格
display("中间计算结果", Tables);
//计算最底下一行
Method maxList
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Integer maxList(List<Fraction> list, boolean isMax, boolean haveInfinity, boolean permitMinus) {
Integer index = null;
//有非数的集合
if (haveInfinity) {
Map<Integer, Fraction> tempMap = new HashMap<>();
Method check
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static boolean check(Color chess[][], int x, int y, Color color) {
int count = 0;
int tempX = x;
int tempY = y;
for (; contains(chess, x - 1, y, color); x--)
Method btnZeroActionPerformed
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
void btnZeroActionPerformed(ActionEvent e) {
if (flag) { //如果刚刚按下了运算符
txtResult.setText("");
if (dotFlag) {//判断之前是否输入了点运算符
txtResult.setText("0." + e.getActionCommand());
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method sampleWithNoRepeated
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static <T> List<T> sampleWithNoRepeated(Map<T, Integer> rateMap, int count) {
List<T> result = new ArrayList<>();
for (int i = 0; i < count; i++) {
int total = 0;
for (Entry<T, Integer> entry : rateMap.entrySet()) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void run() {
while (hero.isAlive() && !exit) {
if (eventGroup.hasPressMoveEvent()) {
// log.info("eventGroup={}", eventGroup);
Identical blocks of code found in 2 locations. Consider refactoring. Open
try {
// 设置解密模式为AES的CBC模式
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES");
IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16));
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 108.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
try {
// 设置解密模式为AES的CBC模式
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES");
IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16));
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 108.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method singleThreadMode
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void singleThreadMode() throws InterruptedException {
Thread normal = new Thread(() -> log.info("normal"));
normal.setName("normal");
normal.start();
Method installGCMonitoring
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void installGCMonitoring() {
//get all the GarbageCollectorMXBeans - there's one for each heap generation
//so probably two - the old generation and young generation
List<GarbageCollectorMXBean> gcbeans = java.lang.management.ManagementFactory.getGarbageCollectorMXBeans();
//Install a notifcation handler for each bean
Method action
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private void action() {
if (state == PersonState.FREEZE) {
return;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"