Kuangcp/JavaBase

View on GitHub

Showing 360 of 360 total issues

Consider simplifying this complex logical expression.
Open

                        if ((you.getX() - 15 <= me.getX() - 15 &&
                                you.getX() + 15 >= me.getX() - 15 &&
                                you.getY() - 10 <= me.getY() - 10 &&
                                you.getY() + 10 >= me.getY() - 10)
                                ||
Severity: Critical
Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

                            if ((you.getX() - 10 <= me.getX() - 10 &&
                                    you.getX() + 10 >= me.getX() - 10 &&
                                    you.getY() - 15 <= me.getY() - 15 &&
                                    you.getY() + 15 >= me.getY() - 15)
                                    ||
    Severity: Critical
    Found in gui/src/main/java/com/github/kuangcp/tank/util/TankTool.java - About 1 hr to fix

      Method run has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public void run() {
              File soundFile = new File(filename);
      
              AudioInputStream audioInputStream;
              try {
      Severity: Minor
      Found in gui/src/main/java/com/github/kuangcp/tank/util/Audio.java - About 1 hr to fix

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

            public void createI(List<Iron> irons, int startX, int startY, int endX, int endY) {
                Iron template = new Iron(0, 0);
                for (int i = startX; i < endX; i += template.getWidth()) {
                    for (int j = startY; j < endY; j += template.getHeight()) {
                        Iron bs = new Iron(i, j);
        gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java on lines 386..394

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

        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 void createB(List<Brick> bricks, int startX, int startY, int endX, int endY) {
                Brick template = new Brick(0, 0);
                for (int i = startX; i < endX; i += template.getWidth()) {
                    for (int j = startY; j < endY; j += template.getHeight()) {
                        Brick bs = new Brick(i, j);
        gui/src/main/java/com/github/kuangcp/tank/panel/TankGroundPanel.java on lines 399..407

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

        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 (('a' <= exChar[i] && exChar[i] <= 'z') || ('A' <= exChar[i] && exChar[i] <= 'Z') || exChar[i] == '_' || ('0' <= exChar[i] && exChar[i] <= '9')) {
        algorithms/src/main/java/com/github/kuangcp/parser/expression/Expression.java on lines 170..170

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

        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

                while (('a' <= exChar[i] && exChar[i] <= 'z') || ('A' <= exChar[i] && exChar[i] <= 'Z') || exChar[i] == '_' || ('0' <= exChar[i] && exChar[i] <= '9')) {
        algorithms/src/main/java/com/github/kuangcp/parser/expression/Expression.java on lines 72..72

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

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

            public static BigDecimal expCalculate(Expression expression) {
                List<ExpressionWord> postfix = getPostfix(expression);  //获取表达式的后缀表达式
                Stack<BigDecimal> result = new Stack<>();  //操作数栈
                if (postfix != null && postfix.size() > 0) {
                    for (int i = 0; i < postfix.size(); i++) {

          Method doScanPackageClassesByFile has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private void doScanPackageClassesByFile(
                Set<Class<?>> classes,
                String packageName,
                String packagePath,
                final boolean recursive) {
          Severity: Minor
          Found in class/src/main/java/com/github/kuangcp/read/ClassScanner.java - About 1 hr to fix

            Method getPostfix has 32 lines of code (exceeds 25 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<>();  //操作符栈
            
            

              Method main has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static void main(String[] s) {
                      String[] args = {"localhost", "10000"};
                      String serverName = args[0];
                      int port = Integer.parseInt(args[1]);
              
              

                Method in has 32 lines of code (exceeds 25 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);

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

                      public void sendMsg(String msg) {
                          if (StringUtil.isNullOrEmpty(msg)) {
                              return;
                          }
                  
                  
                  Severity: Major
                  Found in netty/src/main/java/netty/halfclose/ClientHandler.java and 1 other location - About 1 hr to fix
                  netty/src/main/java/netty/timeServer/TimeClientHandler.java on lines 66..82

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

                  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

                      public void sendMsg(String msg) {
                          if (StringUtil.isNullOrEmpty(msg)) {
                              return;
                          }
                  
                  
                  Severity: Major
                  Found in netty/src/main/java/netty/timeServer/TimeClientHandler.java and 1 other location - About 1 hr to fix
                  netty/src/main/java/netty/halfclose/ClientHandler.java on lines 72..88

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

                  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 check has a Cognitive Complexity of 11 (exceeds 5 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--)
                  Severity: Minor
                  Found in gui/src/main/java/com/github/kuangcp/gomoku/CheckWin.java - About 1 hr 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 loopEventSpin has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static void loopEventSpin(String type, BlockingQueue<AbstractLoopEvent> queue) {
                          while (true) {
                              try {
                                  final AbstractLoopEvent event = queue.take();
                                  final long delay = event.getDelay(TimeUnit.MILLISECONDS);

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

                    MythBaseStack<Integer> add(String one, String other) {
                      boolean oneResult = initBigInteger(one, oneStack);
                      boolean otherResult = initBigInteger(other, otherStack);
                      if (!oneResult || !otherResult) {
                        return null;

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

                    private void calculateResult(List<String> expression) {
                      for (String row : expression) {
                        if (row.length() >= num) {
                          int temp = 0;
                          StringBuilder buffer = new StringBuilder();

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

                      private void finallyResult() throws Exception {
                          Integer RightMin = maxList(Os, false, true, false);
                          boolean SUCCESS = true;
                          if (RightMin == -1) {
                              System.out.println("右列没有一个正数,最后一行也没有正数,原方程没有最优解");

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

                    private void doScanPackageClassesByFile(
                        Set<Class<?>> classes,
                        String packageName,
                        String packagePath,
                        final boolean recursive) {
                  Severity: Minor
                  Found in class/src/main/java/com/github/kuangcp/read/ClassScanner.java - About 1 hr 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

                  Severity
                  Category
                  Status
                  Source
                  Language