guimc233/lgz-bot

View on GitHub

Showing 27 of 108 total issues

Method filter has a Cognitive Complexity of 136 (exceeds 20 allowed). Consider refactoring.
Open

    suspend fun filter(e: GroupMessageEvent) {
        if (!ModuleStateConfig.messageFilter) return
        var muted = false
        // 检查权限

Severity: Minor
Found in src/main/kotlin/ltd/guimc/lgzbot/listener/message/MessageFilter.kt - About 2 days 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 ltd_guimc_command_hypixel has a Cognitive Complexity of 116 (exceeds 20 allowed). Consider refactoring.
Open

    fun CommandSender.ltd_guimc_command_hypixel(name: String) = launch {
        try {
            requireNotNull(bot) { "Must have bot to use it" }
            requireNotNull(user) { "Must have user to use it" }

Severity: Minor
Found in src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt - About 2 days 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 predict has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

    public static int predict(double[] input, String[] script) {
        double[] current = new double[input.length];
        System.arraycopy(input, 0, current, 0, input.length);
        for (String str : script) {
            if (str.length() < 2) {
Severity: Minor
Found in src/main/java/huzpsb/ll4j/minrt/MinRt.java - About 1 day 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 filter has 175 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    suspend fun filter(e: GroupMessageEvent) {
        if (!ModuleStateConfig.messageFilter) return
        var muted = false
        // 检查权限

Severity: Major
Found in src/main/kotlin/ltd/guimc/lgzbot/listener/message/MessageFilter.kt - About 7 hrs to fix

    Method update has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        public void update(String text) {
            text = CharUtils.regularize(text);
            LinkedList<String> engStr = new LinkedList<>();
            if (smartEnglishContext) {
                int[] charArray = text.codePoints().toArray();
    Severity: Minor
    Found in src/main/java/huzpsb/ll4j/nlp/token/TokenizerBuilder.java - About 6 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

    File HypixelCommand.kt has 384 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * THIS FILE IS PART OF lgz-bot PROJECT
     *
     * You must disclose the source code of your modified work and the source code you took from this project. This means you are not allowed to use code from this project (even partially) in a closed-source (or even obfuscated) application.
     * Your modified application must also be licensed under the AGPLv3.
    Severity: Minor
    Found in src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt - About 5 hrs to fix

      File Model.java has 335 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package huzpsb.ll4j.model;
      
      import huzpsb.ll4j.layer.*;
      import huzpsb.ll4j.utils.data.DataEntry;
      import huzpsb.ll4j.utils.data.DataSet;
      Severity: Minor
      Found in src/main/java/huzpsb/ll4j/model/Model.java - About 4 hrs to fix

        Method iiIiIIiII1i1I1i1I1i1II1i1I1i1I1 has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring.
        Open

            @Handler
            fun CommandSender.iiIiIIiII1i1I1i1I1i1II1i1I1i1I1(id: Long) = launch {
                try {
                    if (bot == null) {
                        throw IllegalAccessError("请勿在控制台运行")
        Severity: Minor
        Found in src/main/kotlin/ltd/guimc/lgzbot/command/ReviewCommand.kt - About 3 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 predict has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static int predict(double[] input, String[] script) {
                double[] current = new double[input.length];
                System.arraycopy(input, 0, current, 0, input.length);
                for (String str : script) {
                    if (str.length() < 2) {
        Severity: Major
        Found in src/main/java/huzpsb/ll4j/minrt/MinRt.java - About 3 hrs to fix

          Method onPush has a Cognitive Complexity of 37 (exceeds 20 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 3 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 trainOn has a Cognitive Complexity of 15 (exceeds 5 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

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

              public void update(String text) {
                  text = CharUtils.regularize(text);
                  LinkedList<String> engStr = new LinkedList<>();
                  if (smartEnglishContext) {
                      int[] charArray = text.codePoints().toArray();
          Severity: Minor
          Found in src/main/java/huzpsb/ll4j/nlp/token/TokenizerBuilder.java - About 1 hr to fix

            Method trainAndGetWA has a Cognitive Complexity of 14 (exceeds 5 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

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

                suspend fun onMessage(event: GroupMessageEvent) {
                    when(event.message.getPlainText()) {
                        "摸鱼", "摸鱼!", "摸鱼.",
                        "摸鱼!", "摸鱼。" -> {
                            if (ModuleStateConfig.moyu) {
            Severity: Minor
            Found in src/main/kotlin/ltd/guimc/lgzbot/listener/message/FunListener.kt - 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 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 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 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 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
                          Severity
                          Category
                          Status
                          Source
                          Language