SmashKs/OneShoot

View on GitHub
presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt

Summary

Maintainability
F
3 days
Test Coverage

Method onTouchEvent has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
Open

    override fun onTouchEvent(event: MotionEvent): Boolean {
        when (event.action) {
            ACTION_DOWN -> {
                // Four angles' area.
                fourAngles.forEach searching@{

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

    override fun onDraw(canvas: Canvas) {
        canvas.apply {
            // Create a new canvas for doing interaction layer.
            saveLayer(wholeRectangle, null).apply {
                // All background rectangle (DST layer).

    Method onTouchEvent has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override fun onTouchEvent(event: MotionEvent): Boolean {
            when (event.action) {
                ACTION_DOWN -> {
                    // Four angles' area.
                    fourAngles.forEach searching@{

      File SelectableAreaView.kt has 263 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*
       * Copyright (C) 2018 The Smash Ks Open Project
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.

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

                                    drawRect(it.coordination.x + SHIFT,
                                             it.coordination.y + SHIFT,
                                             it.coordination.x + DEFAULT_TOUCH_RANGE + SHIFT,
                                             it.coordination.y + DEFAULT_TOUCH_RANGE + SHIFT,
                                             paintInnerRect)
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 238..242

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

        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

                                    drawRect(it.coordination.x - DEFAULT_TOUCH_RANGE - SHIFT,
                                             it.coordination.y - DEFAULT_TOUCH_RANGE - SHIFT,
                                             it.coordination.x - SHIFT,
                                             it.coordination.y - SHIFT,
                                             paintInnerRect)
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 252..256

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

        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

                                    drawRect(it.coordination.x + DEFAULT_STROKE_HALF_WIDTH,
                                             it.coordination.y - DEFAULT_STROKE_HALF_WIDTH - DEFAULT_TOUCH_RANGE,
                                             it.coordination.x + DEFAULT_STROKE_HALF_WIDTH + DEFAULT_TOUCH_RANGE,
                                             it.coordination.y - DEFAULT_STROKE_HALF_WIDTH,
                                             paintAngles)
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 272..276

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

        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

                                    drawRect(it.coordination.x + SHIFT,
                                             it.coordination.y - DEFAULT_TOUCH_RANGE - SHIFT,
                                             it.coordination.x + DEFAULT_TOUCH_RANGE + SHIFT,
                                             it.coordination.y - SHIFT,
                                             paintInnerRect)
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 266..270

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

        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

                                    drawRect(it.coordination.x - DEFAULT_STROKE_HALF_WIDTH - DEFAULT_TOUCH_RANGE,
                                             it.coordination.y - DEFAULT_STROKE_HALF_WIDTH - DEFAULT_TOUCH_RANGE,
                                             it.coordination.x - DEFAULT_STROKE_HALF_WIDTH,
                                             it.coordination.y - DEFAULT_STROKE_HALF_WIDTH,
                                             paintAngles)
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 258..262

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

        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

                                    drawRect(it.coordination.x + DEFAULT_STROKE_HALF_WIDTH,
                                             it.coordination.y + DEFAULT_STROKE_HALF_WIDTH,
                                             it.coordination.x + DEFAULT_STROKE_HALF_WIDTH + DEFAULT_TOUCH_RANGE,
                                             it.coordination.y + DEFAULT_STROKE_HALF_WIDTH + DEFAULT_TOUCH_RANGE,
                                             paintAngles)
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 244..248

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

        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

                    drawRect(leftTopPoint.coordination.x,
                             leftTopPoint.coordination.y,
                             rightBottomPoint.coordination.x,
                             rightBottomPoint.coordination.y,
                             paintRect)
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 219..223

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

        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

                        drawRect(leftTopPoint.coordination.x,
                                 leftTopPoint.coordination.y,
                                 rightBottomPoint.coordination.x,
                                 rightBottomPoint.coordination.y,
                                 paintInnerRect)
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 226..230

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

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

                /**
                 * The left top point of a rectangle.
                 */
                class LT(
                    isSelected: Boolean,
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 320..326
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 328..334
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 336..342

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

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

                /**
                 * The right bottom point of a rectangle.
                 */
                class RB(
                    isSelected: Boolean,
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 311..318
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 320..326
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 328..334

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

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

                /**
                 * The right top point of a rectangle.
                 */
                class RT(
                    isSelected: Boolean,
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 311..318
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 320..326
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 336..342

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

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

                /**
                 * The left bottom point of a rectangle.
                 */
                class LB(
                    isSelected: Boolean,
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 311..318
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 328..334
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/customize/selectable/SelectableAreaView.kt on lines 336..342

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

        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

        class SelectableAreaView @JvmOverloads constructor(
            context: Context,
            attrs: AttributeSet? = null,
            defStyleAttr: Int = 0
        ) : FrameLayout(context, attrs, defStyleAttr) {
        presentation/src/main/java/smash/ks/com/oneshoot/widgets/textview/FontTextView.kt on lines 28..32

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

        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

        There are no issues that match your filters.

        Category
        Status