guimc233/lgz-bot

View on GitHub

Showing 108 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

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

                                    "Skywars 信息:\n" +
                                        "等级: ${
                                            try {
                                                (ExpCalculator.getSkyWarsLevel(swStats.getIntOrNull("experience")) * 100).roundToInt()
                                                    .toDouble() / 100.0
    Severity: Major
    Found in src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt and 1 other location - About 5 hrs to fix
    src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt on lines 144..162

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

    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

                                    "Bedwars 信息:\n" +
                                        "等级: ${
                                            try {
                                                (ExpCalculator.getBedWarsLevel(bwStats.getIntOrNull("Experience")) * 100).roundToInt()
                                                    .toDouble() / 100.0
    Severity: Major
    Found in src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt and 1 other location - About 5 hrs to fix
    src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt on lines 186..204

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

    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

    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

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

                                      "Duels 信息:\n" +
                                          "硬币: ${duelStats.getInt("coins")}\n" +
                                          "总游戏数: ${duelStats.getIntOrNull("rounds_played")}\n" +
                                          "胜利/失败: ${duelStats.getIntOrNull("wins")}/${duelStats.getIntOrNull("losses")} " +
                                          "WLR: ${
      Severity: Major
      Found in src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt and 1 other location - About 5 hrs to fix
      src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt on lines 311..327

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

      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

                                      "UHC 信息:\n" +
                                          "硬币: ${uhcStats.getIntOrNull("coins")}\n" +
                                          "已选择的职业 ${uhcStats.getStringOrNull("equippedKit")}\n" +
                                          "胜利/失败: ${uhcStats.getIntOrNull("wins")}/${uhcStats.getIntOrNull("deaths")} " +
                                          "WLR: ${
      Severity: Major
      Found in src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt and 1 other location - About 5 hrs to fix
      src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt on lines 229..245

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

      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

          @SubCommand("spam")
          @Description("开/关刷屏检查")
          suspend fun CommandSender.iI1I1i11ii1I1i1I1i() {
              if (getGroupOrNull() == null) {
                  sendMessage("请在群聊中执行该命令")
      src/main/kotlin/ltd/guimc/lgzbot/command/ToggleCheckCommand.kt on lines 42..63

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

      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

          @SubCommand("ad")
          @Description("开/关广告检测")
          suspend fun CommandSender.iiI11i1I1i1II1i1I1ii1I1i1I1() {
              if (getGroupOrNull() == null) {
                  sendMessage("请在群聊中执行该命令")
      src/main/kotlin/ltd/guimc/lgzbot/command/ToggleCheckCommand.kt on lines 19..40

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

      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

          fun getJsonObject(url: String, auth: String? = null): JSONObject {
              val connection = java.net.URL(url).openConnection() as java.net.HttpURLConnection
              connection.requestMethod = "GET"
              if (auth != null) {
                  val basicAuth = "Basic : " + String(Base64.getEncoder().encode(auth.toByteArray()))
      Severity: Major
      Found in src/main/kotlin/ltd/guimc/lgzbot/utils/HttpUtils.kt and 1 other location - About 4 hrs to fix
      src/main/kotlin/ltd/guimc/lgzbot/utils/HttpUtils.kt on lines 30..41

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

      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

          fun getJsonArray(url: String, auth: String? = null): JSONArray {
              val connection = java.net.URL(url).openConnection() as java.net.HttpURLConnection
              connection.requestMethod = "GET"
              if (auth != null) {
                  val basicAuth = "Basic : " + String(Base64.getEncoder().encode(auth.toByteArray()))
      Severity: Major
      Found in src/main/kotlin/ltd/guimc/lgzbot/utils/HttpUtils.kt and 1 other location - About 4 hrs to fix
      src/main/kotlin/ltd/guimc/lgzbot/utils/HttpUtils.kt on lines 17..28

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

      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

      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

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

                      if (RegexUtils.matchRegex(adRegex, textMessage) && textMessage.length >= stringLength) {
                          try {
                              recalledMessage++
                              e.message.recall()
                              if (predicted) {
          src/main/kotlin/ltd/guimc/lgzbot/listener/message/MessageFilter.kt on lines 108..123

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

          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

                              ) {
                                  try {
                                      recalledMessage++
                                      e.message.recall()
                                      if (predicted) {
          src/main/kotlin/ltd/guimc/lgzbot/listener/message/MessageFilter.kt on lines 75..90

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

          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

          Severity
          Category
          Status
          Source
          Language