whitewind664/sdp

View on GitHub

Showing 7 of 7 total issues

Method playMove has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
Open

    /**
     * Executes a given move, throwing an exception if the move is illegal. Returns the number of
     * stones captured by the move.
     *
     * @param m move to play
Severity: Minor
Found in app/src/main/java/com/github/gogetters/letsgo/game/Board.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 toCommand has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
Open

        /**
         * Command deserialization helper function.
         */
        fun toCommand(s: String): GTPCommand {
            val decomposed = s.split(" ")
Severity: Minor
Found in app/src/main/java/com/github/gogetters/letsgo/game/GTPCommand.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 onCreate has 52 lines of code (exceeds 50 allowed). Consider refactoring.
Open

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        val gameSizeInput = intent.getIntExtra(EXTRA_GAME_SIZE, 9)
        val komi = intent.getDoubleExtra(EXTRA_KOMI, 5.5)

    Avoid deeply nested control flow statements.
    Open

                            for (enemy in enemyGroup) {
                                board[enemy] = Stone.EMPTY
                                capturedStones.add(enemy)
                            }
    Severity: Major
    Found in app/src/main/java/com/github/gogetters/letsgo/game/Board.kt - About 45 mins to fix

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

              fun sendMessage(senderId: String, chatId: String, messageText: String, onSuccess: () -> Unit, onFailure: (Exception) -> Unit) {
      Severity: Minor
      Found in app/src/main/java/com/github/gogetters/letsgo/database/Database.kt - About 35 mins to fix

        Method findMatch has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

                fun findMatch(ranked: Boolean, onFind: (String, Stone) -> Unit, onFail: () -> Unit) {
                    val user = Authentication.getCurrentUser()
                    this.onFind = onFind
                    if (user != null) {
                        val ratingPath = "/matchmaking/users/${user.uid}/rating"
        Severity: Minor
        Found in app/src/main/java/com/github/gogetters/letsgo/matchmaking/Matchmaking.kt - 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

        Method onReceive has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
        Open

                @RequiresApi(Build.VERSION_CODES.N)
                override fun onReceive(context: Context, intent: Intent) {
        
                    when (intent.action) {
                        BluetoothDevice.ACTION_FOUND -> {

        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