guimc233/lgz-bot

View on GitHub

Showing 108 of 108 total issues

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

    @EventHandler
    suspend fun MemberMuteEvent.mute() {
        if (!ModuleStateConfig.grouplistener) return
        if (this.operator == null) return
        this.group.sendMessage(format(MUTE.random(), this.member.id, this.operator!!.id))
src/main/kotlin/ltd/guimc/lgzbot/listener/multi/BakaListener.kt on lines 78..83

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

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

    @EventHandler
    suspend fun MemberUnmuteEvent.unmute() {
        if (!ModuleStateConfig.grouplistener) return
        if (this.operator == null) return
        this.group.sendMessage(format(UNMUTE.random(), this.member.id, this.operator!!.id))
src/main/kotlin/ltd/guimc/lgzbot/listener/multi/BakaListener.kt on lines 71..76

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

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

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

        return this.replace(" ", "")
            .replace(",", "")
            .replace(".", "")
            .replace("!", "")
            .replace("?", "")
Severity: Major
Found in src/main/kotlin/ltd/guimc/lgzbot/utils/TextUtils.kt and 1 other location - About 1 hr to fix
src/main/kotlin/ltd/guimc/lgzbot/utils/MojangAPIUtils.kt on lines 12..18

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

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

        return this.replace("§0", "")
            .replace("§1", "")
            .replace("§2", "")
            .replace("§3", "")
            .replace("§4", "")
Severity: Major
Found in src/main/kotlin/ltd/guimc/lgzbot/utils/MojangAPIUtils.kt and 1 other location - About 1 hr to fix
src/main/kotlin/ltd/guimc/lgzbot/utils/TextUtils.kt on lines 55..61

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

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

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

                if (!cooldown.isTimePassed(user!!)) {
                    if (cooldown.shouldSendCooldownNotice(user!!)) sendMessage("你可以在 ${cooldown.getLeftTime(user!!) / 1000} 秒后继续使用该指令")
                    return@launch
                }
    Severity: Major
    Found in src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt and 1 other location - About 1 hr to fix
    src/main/kotlin/ltd/guimc/lgzbot/command/FbCommand.kt on lines 34..37

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

    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 (!cooldown.isTimePassed(user!!)) {
                if (cooldown.shouldSendCooldownNotice(user!!)) sendMessage("你可以在 ${cooldown.getLeftTime(user!!) / 1000} 秒后继续使用该指令")
                return@launch
            }
    Severity: Major
    Found in src/main/kotlin/ltd/guimc/lgzbot/command/FbCommand.kt and 1 other location - About 1 hr to fix
    src/main/kotlin/ltd/guimc/lgzbot/command/HypixelCommand.kt on lines 46..49

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

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

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

                    for (regex in regexList) {
                        i++
                        if (regex.containsMatchIn(unPeekText)) {
                            logger.info("匹配成功 在第${i}行 ${regex.find(unPeekText)?.value}")
                            return true
        Severity: Major
        Found in src/main/kotlin/ltd/guimc/lgzbot/utils/RegexUtils.kt and 1 other location - About 1 hr to fix
        src/main/kotlin/ltd/guimc/lgzbot/utils/RegexUtils.kt on lines 55..61

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

        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

                    for (regex in regexList) {
                        i++
                        if (regex.containsMatchIn(unPeekText)) {
                            logger.info("匹配成功 在第${i}行 ${regex.find(unPeekText)?.value}")
                            return true
        Severity: Major
        Found in src/main/kotlin/ltd/guimc/lgzbot/utils/RegexUtils.kt and 1 other location - About 1 hr to fix
        src/main/kotlin/ltd/guimc/lgzbot/utils/RegexUtils.kt on lines 73..79

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

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

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

                        for (int i = 0; i < layers.length; i++) {
                            layers[i].training = true;
                            layers[i].forward();
                            if (i < layers.length - 1) {
                                layers[i + 1].input = layers[i].output;
            Severity: Major
            Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 1 hr to fix
            src/main/java/huzpsb/ll4j/model/Model.java on lines 76..82
            src/main/java/huzpsb/ll4j/model/Model.java on lines 104..110
            src/main/java/huzpsb/ll4j/model/Model.java on lines 127..133

            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 4 locations. Consider refactoring.
            Open

                        for (int i = 0; i < layers.length; i++) {
                            layers[i].training = true;
                            layers[i].forward();
                            if (i < layers.length - 1) {
                                layers[i + 1].input = layers[i].output;
            Severity: Major
            Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 1 hr to fix
            src/main/java/huzpsb/ll4j/model/Model.java on lines 40..46
            src/main/java/huzpsb/ll4j/model/Model.java on lines 104..110
            src/main/java/huzpsb/ll4j/model/Model.java on lines 127..133

            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 4 locations. Consider refactoring.
            Open

                        for (int i = 0; i < layers.length; i++) {
                            layers[i].training = false;
                            layers[i].forward();
                            if (i < layers.length - 1) {
                                layers[i + 1].input = layers[i].output;
            Severity: Major
            Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 1 hr to fix
            src/main/java/huzpsb/ll4j/model/Model.java on lines 40..46
            src/main/java/huzpsb/ll4j/model/Model.java on lines 76..82
            src/main/java/huzpsb/ll4j/model/Model.java on lines 127..133

            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 4 locations. Consider refactoring.
            Open

                        for (int i = 0; i < layers.length; i++) {
                            layers[i].training = false;
                            layers[i].forward();
                            if (i < layers.length - 1) {
                                layers[i + 1].input = layers[i].output;
            Severity: Major
            Found in src/main/java/huzpsb/ll4j/model/Model.java and 3 other locations - About 1 hr to fix
            src/main/java/huzpsb/ll4j/model/Model.java on lines 40..46
            src/main/java/huzpsb/ll4j/model/Model.java on lines 76..82
            src/main/java/huzpsb/ll4j/model/Model.java on lines 104..110

            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 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
              Severity
              Category
              Status
              Source
              Language