Kuangcp/JavaBase

View on GitHub

Showing 349 of 349 total issues

Tank has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

@Slf4j
public abstract class Tank extends AbstractLoopEvent implements VisualItem {
    int x;          // 坦克中心的横坐标
    int y;          // 坦克中心的纵坐标
    int direct = 0;   // 初始方向
Severity: Minor
Found in gui/src/main/java/com/github/kuangcp/tank/domain/Tank.java - About 2 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public static void encryptFile(String algorithm, SecretKey key, IvParameterSpec iv,
                                       File inputFile, File outputFile) throws IOException, NoSuchPaddingException,
                NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException,
                BadPaddingException, IllegalBlockSizeException {
            Cipher cipher = Cipher.getInstance(algorithm);
    Severity: Major
    Found in class/src/main/java/security/aes/AESUtil.java and 1 other location - About 2 hrs to fix
    class/src/main/java/security/aes/AESUtil.java on lines 108..130

    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 168.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public static void decryptFile(String algorithm, SecretKey key, IvParameterSpec iv,
                                       File encryptedFile, File decryptedFile) throws IOException, NoSuchPaddingException,
                NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException,
                BadPaddingException, IllegalBlockSizeException {
            Cipher cipher = Cipher.getInstance(algorithm);
    Severity: Major
    Found in class/src/main/java/security/aes/AESUtil.java and 1 other location - About 2 hrs to fix
    class/src/main/java/security/aes/AESUtil.java on lines 84..106

    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 168.

    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

    Further Reading

    Method findDiffIndexPoint has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        public static int findDiffIndexPoint(String a, String b) {
            if (StringUtils.equals(a, b)) {
                return 0;
            }
            if (Objects.isNull(a)) {

    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 in has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      T in(Class<T> target, InputStream inputStream) {
        T object = null;
        try {
          Reader reader = new InputStreamReader(inputStream);
          BufferedReader bufferedReader = new BufferedReader(reader);

    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 TimeWheel.java has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package com.github.kuangcp.time.wheel;
    
    import lombok.extern.slf4j.Slf4j;
    
    import java.time.Duration;
    Severity: Minor
    Found in algorithms/src/main/java/com/github/kuangcp/time/wheel/TimeWheel.java - About 2 hrs to fix

      Method findDiffIndex has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public static int findDiffIndex(String a, String b) {
              if (StringUtils.equals(a, b)) {
                  return 0;
              }
              if (Objects.isNull(a)) {

      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 saveDataBase has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public void saveDataBase() {
              PreparedStatement ps = null;
              Connection cn = null;
              ResultSet rs = null;
      
      
      Severity: Minor
      Found in gui/src/main/java/com/github/kuangcp/tank/util/Saved.java - About 2 hrs to fix

      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 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public void readAll() {
              InputStream input = null;
              BufferedReader br = null;
              InputStreamReader ids = null;
              try {
      Severity: Major
      Found in gui/src/main/java/com/github/kuangcp/tank/util/Saved.java - About 2 hrs to fix

        Expression has 22 methods (exceeds 20 allowed). Consider refactoring.
        Open

        public class Expression {
        
            private String expression;  //算术表达式字符串
            private final List<ExpressionWord> expressionWord; //存储表达式词法分析所得的单词与该单词所对应的种别编码的集合
            private int index;  //读取词法分析器的字符游标

          File Calculator.java has 263 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package com.github.kuangcp.caculator;
          
          
          import java.awt.Dimension;
          import java.awt.Font;
          Severity: Minor
          Found in gui/src/main/java/com/github/kuangcp/caculator/Calculator.java - About 2 hrs to fix

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                            if (i == exChar.length - 1) {
                                switch (exChar[i]) {
                                    case '+':
                                        expressionWord.add(new ExpressionWord("+", 1));
                                        break;
            algorithms/src/main/java/com/github/kuangcp/parser/expression/Expression.java on lines 80..106

            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 146.

            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

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                            if (i == exChar.length - 1) {
                                switch (exChar[i]) {
                                    case '+':
                                        expressionWord.add(new ExpressionWord("+", 1));
                                        break;
            algorithms/src/main/java/com/github/kuangcp/parser/expression/Expression.java on lines 122..148

            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 146.

            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

            Further Reading

            Method startNewRound has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public void startNewRound() {
                    enemyList = new CopyOnWriteArrayList<>();
                    bricks = new CopyOnWriteArrayList<>();
                    irons = new CopyOnWriteArrayList<>();
            
            
            Severity: Minor
            Found in gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java - About 2 hrs to fix

            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 pushTimeWheel has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                private void pushTimeWheel(int seconds) {
                    Map<ChronoUnit, Integer> tempIndex = new HashMap<>(sortedSlots.size());
                    for (int i = 0; i < sortedSlots.size(); i++) {
                        ChronoUnit unit = sortedSlots.get(i);
                        Integer threshold = slots.get(unit);
            Severity: Minor
            Found in algorithms/src/main/java/com/github/kuangcp/time/wheel/TimeWheel.java - About 2 hrs to fix

            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 startNewRound has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public void startNewRound() {
                    enemyList = new CopyOnWriteArrayList<>();
                    bricks = new CopyOnWriteArrayList<>();
                    irons = new CopyOnWriteArrayList<>();
            
            
            Severity: Major
            Found in gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java - About 2 hrs to fix

              File Saved.java has 255 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              package com.github.kuangcp.tank.util;
              
              import com.github.kuangcp.tank.domain.Brick;
              import com.github.kuangcp.tank.domain.EnemyTank;
              import com.github.kuangcp.tank.domain.Hero;
              Severity: Minor
              Found in gui/src/main/java/com/github/kuangcp/tank/util/Saved.java - About 2 hrs to fix

                Method findEffectiveArea has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    private void findEffectiveArea() {
                        for (int i = 0; i <= 14; i++) {
                            for (int j = 0; j <= 14; j++)
                                if (chess[i][j] != null) {
                                    effectiveX1 = i;
                Severity: Minor
                Found in gui/src/main/java/com/github/kuangcp/gomoku/AI.java - About 2 hrs to fix

                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 quickSort has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                  public <T extends Comparable<? super T>> T[] quickSort(T[] data, int start, int end) {
                    int low = start + 1, high = end;
                    T key = data[start];
                
                    if (start >= end) {
                Severity: Minor
                Found in algorithms/src/main/java/com/github/kuangcp/sort/Quick.java - About 2 hrs to fix

                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 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    public void run() throws Exception {
                        init();
                //运算出初始的表格
                        display("中间计算结果", Tables);
                        //计算最底下一行

                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

                Severity
                Category
                Status
                Source
                Language