Showing 349 of 349 total issues
File TankGroundPanel.java
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
package com.github.kuangcp.tank.panel;
import com.github.kuangcp.tank.domain.Brick;
import com.github.kuangcp.tank.domain.Bullet;
import com.github.kuangcp.tank.domain.EnemyTank;
Method ablePass
has a Cognitive Complexity of 25 (exceeds 5 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();
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int i = 0; i < et.bulletList.size(); i++) {
Bullet myBullet = et.bulletList.get(i);
for (Brick brick : bricks) {
TankTool.judgeHint(myBullet, brick);
}
- 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 216.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
for (int i = 0; i < hero.bulletList.size(); i++) {
Bullet myBullet = hero.bulletList.get(i);
for (Brick brick : bricks) {
TankTool.judgeHint(myBullet, brick);
}
- 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 216.
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 sort
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public int[] sort(int[] data) {
int[] arr = Arrays.copyOf(data, data.length);
List<List<Integer>> dataList = new ArrayList<>();
List<Integer> arrs = new ArrayList<>();
- 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 a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
public void run(){
try{
br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
ps = new PrintStream(socket.getOutputStream());
String line = null;
- 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 main
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void main(String[] args) {
for (int k = 0; k < minSize; k++) {
stack[k] = new Point();
path[k] = new Point();
}
Method countToScore
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
private int countToScore(int count, int block, Color color) {
if (block == 2)
return 0;
if (count == 5 && color == myColor)
return 0x3b9aca00;
- 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 readAll
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public void readAll() {
InputStream input = null;
BufferedReader br = null;
InputStreamReader ids = null;
try {
- 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 getPostfix
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public static List<ExpressionWord> getPostfix(Expression expression) {
List<ExpressionWord> midfix = expression.getWord(); //获取中缀表达式的经过词法分析器分析的结果集
List<ExpressionWord> result = new ArrayList<>(); //存储后缀表达式结果的List集合
Stack<ExpressionWord> operationStack = new Stack<>(); //操作符栈
- 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
File SimplexMethodWithFraction.java
has 288 lines of code (exceeds 250 allowed). Consider refactoring. Open
package com.github.kuangcp.simplex.method;
import com.github.kuangcp.math.number.Fraction;
import lombok.extern.slf4j.Slf4j;
Similar blocks of code found in 2 locations. Consider refactoring. Open
case DirectType.DOWN:
final int downY = t.getY() + halfHeight;
if (leftX >= h.getHx() && leftX <= h.getHx() + hx
&& downY >= h.getHy() && downY <= h.getHy() + hy
|| t.getX() >= h.getHx() && t.getX() <= h.getHx() + hx
- 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 176.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
case DirectType.UP:
final int upY = t.getY() - halfHeight;
if (leftX >= h.getHx() && leftX <= h.getHx() + hx
&& upY >= h.getHy() && upY <= h.getHy() + hy
|| t.getX() >= h.getHx() && t.getX() <= h.getHx() + hx
- 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 176.
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 savedAll
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public void savedAll() {
BufferedWriter bw = null;
OutputStream out = null;
OutputStreamWriter os = null;
- 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 handleNotification
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void handleNotification(Notification notification, Object handback) {
//we only handle GARBAGE_COLLECTION_NOTIFICATION notifications here
if (notification.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
//get the information associated with this notification
- 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 paint
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void paint(Graphics g) {
super.paint(g);
if (Objects.isNull(hero)) {
hero = new Hero(20, 20, 4);
Consider simplifying this complex logical expression. Open
if (t.getX() - halfHeight >= h.getHx() && t.getX() - halfHeight <= h.getHx() + hx
&& t.getY() - halfWidth >= h.getHy() && t.getY() - halfWidth <= h.getHy() + hy
|| t.getX() - halfHeight >= h.getHx() && t.getX() - halfHeight <= h.getHx() + hx
&& t.getY() >= h.getHy() && t.getY() <= h.getHy() + hy
|| t.getX() - halfHeight >= h.getHx() && t.getX() - halfHeight <= h.getHx() + hx
Consider simplifying this complex logical expression. Open
if (leftX >= h.getHx() && leftX <= h.getHx() + hx
&& upY >= h.getHy() && upY <= h.getHy() + hy
|| t.getX() >= h.getHx() && t.getX() <= h.getHx() + hx
&& upY >= h.getHy() && upY <= h.getHy() + hy
|| rightX >= h.getHx() && rightX <= h.getHx() + hx
Consider simplifying this complex logical expression. Open
if (leftX >= h.getHx() && leftX <= h.getHx() + hx
&& downY >= h.getHy() && downY <= h.getHy() + hy
|| t.getX() >= h.getHx() && t.getX() <= h.getHx() + hx
&& downY >= h.getHy() && downY <= h.getHy() + hy
|| rightX >= h.getHx() && rightX <= h.getHx() + hx
Consider simplifying this complex logical expression. Open
if (t.getX() + halfHeight >= h.getHx() - 2 && t.getX() + halfHeight <= h.getHx() + hx
&& t.getY() + halfWidth >= h.getHy() && t.getY() + halfWidth <= h.getHy() + hy
|| t.getX() + halfHeight >= h.getHx() - 2 && t.getX() + halfHeight <= h.getHx() + hx
&& t.getY() >= h.getHy() && t.getY() <= h.getHy() + hy
|| t.getX() + halfHeight >= h.getHx() - 2 && t.getX() + halfHeight <= h.getHx() + hx