guimc233/lgz-bot

View on GitHub

Showing 7 of 38 total issues

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

    suspend fun filter(e: GroupMessageEvent) {
        var muted = false
        // 检查权限

        val textMessage = e.message.getPlainText()
Severity: Minor
Found in src/main/kotlin/ltd/guimc/lgzbot/listener/message/MessageFilter.kt - 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 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    suspend fun filter(e: GroupMessageEvent) {
        var muted = false
        // 检查权限

        val textMessage = e.message.getPlainText()
Severity: Major
Found in src/main/kotlin/ltd/guimc/lgzbot/listener/message/MessageFilter.kt - About 4 hrs to fix

    Method iiIiIIiII1i1I1i1I1i1II1i1I1i1I1 has a Cognitive Complexity of 38 (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 specialCheck has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        suspend fun specialCheck(e: GroupMessageEvent, textMessage: String) {
            val name = PinyinUtils.convertToPinyin(textMessage).lowercase().replace(" ", "")
            when {
                (((name.contains("chen") || name.contains("cheng") || name.contains("cen")) &&
                    (name.contains("zi") || name.contains("zhi")) &&
    Severity: Major
    Found in src/main/kotlin/ltd/guimc/lgzbot/special/CZXTeacher.kt - About 2 hrs to fix

      Method specialCheck has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
      Open

          suspend fun specialCheck(e: GroupMessageEvent, textMessage: String) {
              val name = PinyinUtils.convertToPinyin(textMessage).lowercase().replace(" ", "")
              when {
                  (((name.contains("chen") || name.contains("cheng") || name.contains("cen")) &&
                      (name.contains("zi") || name.contains("zhi")) &&
      Severity: Minor
      Found in src/main/kotlin/ltd/guimc/lgzbot/special/CZXTeacher.kt - 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 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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