guimc233/lgz-bot

View on GitHub

Showing 46 of 148 total issues

Method initEngine has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public void initEngine(Model model, HardwareConfig hardwareConfig) {
        if (!isInit) {
            synchronized (this) {
                if (!isInit) {
                    initLogger(false, false, false);
Severity: Minor
Found in src/main/java/com/benjaminwan/ocrlibrary/OcrEngine.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 onMessage has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    suspend fun onMessage(event: GroupMessageEvent) {
        when(event.message.getPlainText()) {
            "${COMMAND_PREFIX}摸鱼", "${COMMAND_PREFIX}摸鱼!", "${COMMAND_PREFIX}摸鱼.",
            "${COMMAND_PREFIX}摸鱼!", "${COMMAND_PREFIX}摸鱼。" -> {
                if (ModuleStateConfig.moyu) {
Severity: Minor
Found in src/main/kotlin/ltd/guimc/lgzbot/listener/message/FunListener.kt - About 1 hr to fix

    Method copyFileFromJar has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static synchronized void copyFileFromJar(String filePath, String aimDir, boolean load, boolean deleteOnExit) throws IOException {
    
            // 获取文件名并校验
            String[] parts = filePath.split("/");
            String filename = (parts.length > 1) ? parts[parts.length - 1] : null;
    Severity: Minor
    Found in src/main/java/io/github/mymonstercat/JarFileUtil.java - About 1 hr to fix

      Method resolveGameType has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          fun resolveGameType(gametype: String): String {
              return when (gametype) {
                  "QUAKECRAFT" -> "Quake"
                  "WALLS" -> "Walls"
                  "PAINTBALL" -> "Paintball"
      Severity: Minor
      Found in src/main/kotlin/ltd/guimc/lgzbot/utils/hypixel/HypixelApiUtils.kt - About 1 hr to fix

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

            static LibraryLoader findLibLoader(String engine) {
                Properties props = new Properties();
                try {
                    props.load(new StringReader(loaders));
        
        
        Severity: Minor
        Found in src/main/java/io/github/mymonstercat/ocr/LoadUtil.java - About 1 hr to fix

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

              suspend fun onPush(event: JSONObject) {
                  val repo = event.getJSONObject("repository").getString("full_name")
                  event.getJSONArray("commits").forEach { rawcommit ->
                      val commit = rawcommit as JSONObject
                      val author = commit.getJSONObject("author")
          Severity: Minor
          Found in src/main/kotlin/ltd/guimc/lgzbot/webhook/GithubWebHookReciver.kt - About 1 hr to fix

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

                @SneakyThrows
                public static void loadFileIfNeeded(Model model) {
                    String modelType = model.getModelType();
                    if (InferenceEngine.nativeLoader == null && (isLibraryLoaded.compareAndSet(false, true))) {
                        synchronized (InferenceEngine.class) {
            Severity: Minor
            Found in src/main/java/io/github/mymonstercat/ocr/InferenceEngine.java - About 1 hr to fix

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

                  fun String.unFormatted(): String {
                      return this.replace("§0", "")
                          .replace("§1", "")
                          .replace("§2", "")
                          .replace("§3", "")
              Severity: Minor
              Found in src/main/kotlin/ltd/guimc/lgzbot/utils/MojangAPIUtils.kt - About 1 hr to fix

                Method trainOn has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public Pair<Integer, Integer> trainOn(DataSet dataSet, double learningRate) {
                        int t = 0, f = 0;
                        if (!(layers[layers.length - 1] instanceof JudgeLayer)) {
                            throw new RuntimeException("Last layer is not output layer");
                        }
                Severity: Minor
                Found in src/main/java/huzpsb/ll4j/model/Model.java - About 1 hr to fix

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

                      public List<DataEntry> trainAndGetWA(DataSet dataSet, double learningRate) {
                          LinkedList<DataEntry> entries = new LinkedList<>();
                          if (!(layers[layers.length - 1] instanceof JudgeLayer)) {
                              throw new RuntimeException("Last layer is not output layer");
                          }
                  Severity: Minor
                  Found in src/main/java/huzpsb/ll4j/model/Model.java - About 1 hr to fix

                    Method parseLine has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static AbstractLayer parseLine(String line) {
                            String[] tokens = line.split(" ");
                            switch (tokens[0]) {
                                case "D":
                                    int inputSize = Integer.parseInt(tokens[1]);
                    Severity: Minor
                    Found in src/main/java/huzpsb/ll4j/model/Model.java - About 1 hr to fix

                      Method onNudge has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          suspend fun onNudge(e: NudgeEvent) {
                              val from = e.from as User
                              val timestamp = Instant.now().epochSecond
                      
                              if (e.target != e.bot) return    // 只处理对机器人的戳一戳
                      Severity: Minor
                      Found in src/main/kotlin/ltd/guimc/lgzbot/listener/nudge/AntiNudgeSpam.kt - About 1 hr to fix

                        Method detectInput has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                OcrInput input, int padding, int maxSideLen,
                                float boxScoreThresh, float boxThresh,
                                float unClipRatio, boolean doAngle, boolean mostAngle
                        Severity: Major
                        Found in src/main/java/com/benjaminwan/ocrlibrary/OcrEngine.java - About 1 hr to fix

                          Method detect has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  String input, int padding, int maxSideLen,
                                  float boxScoreThresh, float boxThresh,
                                  float unClipRatio, boolean doAngle, boolean mostAngle
                          Severity: Major
                          Found in src/main/java/com/benjaminwan/ocrlibrary/OcrEngine.java - About 1 hr to fix

                            Method testOn has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public Pair<Integer, Integer> testOn(DataSet dataSet) {
                                    int t = 0, f = 0;
                                    for (DataEntry dataEntry : dataSet.split) {
                                        layers[0].input = dataEntry.values;
                                        for (int i = 0; i < layers.length; i++) {
                            Severity: Minor
                            Found in src/main/java/huzpsb/ll4j/model/Model.java - About 55 mins 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

                            Avoid deeply nested control flow statements.
                            Open

                                                    if (CharUtils.isEnglishLetter(ch)) {
                                                        builder.append(ch);
                                                        i = until;
                                                    }
                                                    else break;
                            Severity: Major
                            Found in src/main/java/huzpsb/ll4j/nlp/token/TokenizerBuilder.java - About 45 mins to fix

                              Method testAndGetWA has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  public List<DataEntry> testAndGetWA(DataSet dataSet) {
                                      LinkedList<DataEntry> entries = new LinkedList<>();
                                      for (DataEntry dataEntry : dataSet.split) {
                                          layers[0].input = dataEntry.values;
                                          for (int i = 0; i < layers.length; i++) {
                              Severity: Minor
                              Found in src/main/java/huzpsb/ll4j/model/Model.java - About 45 mins 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

                              Avoid deeply nested control flow statements.
                              Open

                                                      if (s.contains(substring) || substring.contains(s)) {
                                                          updateVocab(s);
                                                          break;
                                                      }
                              Severity: Major
                              Found in src/main/java/huzpsb/ll4j/nlp/token/TokenizerBuilder.java - About 45 mins to fix

                                Method initModels has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    public native boolean initModels(String modelsDir, String detName, String clsName, String recName, String keysName);
                                Severity: Minor
                                Found in src/main/java/com/benjaminwan/ocrlibrary/OcrEngine.java - About 35 mins to fix

                                  Method equals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      @Override
                                      public boolean equals(Object o) {
                                          if (this == o) return true;
                                          if (o == null || getClass() != o.getClass()) return false;
                                          TextBlock textBlock = (TextBlock) o;
                                  Severity: Minor
                                  Found in src/main/java/com/benjaminwan/ocrlibrary/TextBlock.java - About 35 mins 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