Kuangcp/JavaBase

View on GitHub
gui/src/main/java/com/github/kuangcp/caculator/Calculator.java

Summary

Maintainability
C
7 hrs
Test Coverage

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

    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());
    Severity: Minor
    Found in gui/src/main/java/com/github/kuangcp/caculator/Calculator.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 initLogicButton has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private void initLogicButton() {
        txtResult.setEnabled(false);
        txtResult.setEditable(false);
        txtResult.setHorizontalAlignment(SwingConstants.RIGHT);
        txtResult.setBounds(new Rectangle(33, 19, 310, 34));
    Severity: Minor
    Found in gui/src/main/java/com/github/kuangcp/caculator/Calculator.java - About 1 hr to fix

      Method btnEqualActionPerformed has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        void btnEqualActionPerformed() {
          if (!calculateFlag) { //未曾按下等于运算符
            behind = txtResult.getText();
          } else {
            front = result;
      Severity: Minor
      Found in gui/src/main/java/com/github/kuangcp/caculator/Calculator.java - About 1 hr to fix

        Method btnEqualActionPerformed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          void btnEqualActionPerformed() {
            if (!calculateFlag) { //未曾按下等于运算符
              behind = txtResult.getText();
            } else {
              front = result;
        Severity: Minor
        Found in gui/src/main/java/com/github/kuangcp/caculator/Calculator.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

        There are no issues that match your filters.

        Category
        Status