coding-blocks/CBOnlineApp

View on GitHub
app/src/main/java/com/codingblocks/cbonlineapp/course/CourseSectionListAdapter.kt

Summary

Maintainability
C
1 day
Test Coverage

Method bind has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
Open

        fun bind(item: Sections) = with(itemView) {
            title.text = item.name
            lectures.text = " ${item.contents?.size ?: 0} Items |"
            var duration: Long = 0
            for (subItems in item.contents!!) {

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 (ll.visibility == View.GONE) {
                title.setTextColor(ContextCompat.getColor(ll.context, R.color.orangish))
                ll.visibility = View.VISIBLE
                arrowAnimation = RotateAnimation(
                    0f, 180f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
app/src/main/java/com/codingblocks/cbonlineapp/course/CourseSectionListAdapter.kt on lines 106..116

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

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

            } else {
                title.setTextColor(ContextCompat.getColor(ll.context, R.color.orangish))
                ll.visibility = View.GONE
                arrowAnimation = RotateAnimation(
                    180f, 0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
app/src/main/java/com/codingblocks/cbonlineapp/course/CourseSectionListAdapter.kt on lines 95..106

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

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

    class DiffCallback : DiffUtil.ItemCallback<Sections>() {
        override fun areItemsTheSame(oldItem: Sections, newItem: Sections): Boolean {
            return oldItem.id == newItem.id
        }

app/src/main/java/com/codingblocks/cbonlineapp/commons/InstructorListAdapter.kt on lines 50..58
app/src/main/java/com/codingblocks/cbonlineapp/course/CourseProjectAdapter.kt on lines 34..42
app/src/main/java/com/codingblocks/cbonlineapp/course/adapter/CourseDiffUtil.kt on lines 7..15
app/src/main/java/com/codingblocks/cbonlineapp/course/batches/BatchListAdapter.kt on lines 44..52
app/src/main/java/com/codingblocks/cbonlineapp/course/batches/RunListAdapter.kt on lines 88..96
app/src/main/java/com/codingblocks/cbonlineapp/dashboard/doubts/CommentsListAdapter.kt on lines 52..60
app/src/main/java/com/codingblocks/cbonlineapp/dashboard/doubts/DashboardDoubtListAdapter.kt on lines 98..106
app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/submissions/QuizSubmissionListAdapter.kt on lines 47..55
app/src/main/java/com/codingblocks/cbonlineapp/tracks/TracksListAdapter.kt on lines 75..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 160.

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

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
        return ItemViewHolder(
            LayoutInflater.from(parent.context)
                .inflate(R.layout.item_course_section, parent, false)
        )
app/src/main/java/com/codingblocks/cbonlineapp/admin/doubts/AdminDoubtsListAdapter.kt on lines 18..23
app/src/main/java/com/codingblocks/cbonlineapp/admin/overview/AdminLeaderBoardListAdapter.kt on lines 12..17
app/src/main/java/com/codingblocks/cbonlineapp/campaign/LeaderBoardPagedListAdapter.kt on lines 29..33
app/src/main/java/com/codingblocks/cbonlineapp/commons/InstructorListAdapter.kt on lines 20..25
app/src/main/java/com/codingblocks/cbonlineapp/course/CourseProjectAdapter.kt on lines 16..21
app/src/main/java/com/codingblocks/cbonlineapp/course/batches/BatchListAdapter.kt on lines 20..25
app/src/main/java/com/codingblocks/cbonlineapp/dashboard/doubts/CommentsListAdapter.kt on lines 22..27
app/src/main/java/com/codingblocks/cbonlineapp/dashboard/doubts/DashboardDoubtListAdapter.kt on lines 26..31
app/src/main/java/com/codingblocks/cbonlineapp/dashboard/home/RecentlyPlayedAdapter.kt on lines 28..33
app/src/main/java/com/codingblocks/cbonlineapp/jobs/JobsAdapter.kt on lines 17..21
app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/SectionListAdapter.kt on lines 16..24
app/src/main/java/com/codingblocks/cbonlineapp/mycourse/content/quiz/submissions/QuizSubmissionListAdapter.kt on lines 17..22
app/src/main/java/com/codingblocks/cbonlineapp/mycourse/overview/LeaderBoardListAdapter.kt on lines 23..28
app/src/main/java/com/codingblocks/cbonlineapp/notifications/NotificationsAdapter.kt on lines 20..23

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

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