H-PixelDroid/PixelDroid

View on GitHub

Showing 45 of 117 total issues

Method onCreate has a Cognitive Complexity of 116 (exceeds 20 allowed). Consider refactoring.
Open

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityEditProfileBinding.inflate(layoutInflater)
        setContentView(binding.root)
        setSupportActionBar(binding.topBar)
Severity: Minor
Found in app/src/main/java/org/pixeldroid/app/profile/EditProfileActivity.kt - About 2 days 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 onViewCreated has a Cognitive Complexity of 82 (exceeds 20 allowed). Consider refactoring.
Open

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        binding.topBar.setupWithNavController(findNavController())

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

File ImageCarousel.kt has 478 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package org.pixeldroid.app.postCreation.carousel

import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable

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

        fun bind(post: Status, lifecycleScope: LifecycleCoroutineScope, api: PixelfedAPI,
                 addCollection: Boolean = false, collection: Collection? = null, deleteFromCollection: Boolean = false
        ) {
    
            if ((post.media_attachments?.size ?: 0) == 0){
    Severity: Minor
    Found in app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt - About 5 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 nodeInfoSchema has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
    Open

        private suspend fun nodeInfoSchema(
            normalizedDomain: String,
            clientId: String,
            nodeInfoSchemaUrl: String
        ) = coroutineScope {
    Severity: Minor
    Found in app/src/main/java/org/pixeldroid/app/LoginActivity.kt - About 4 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 onViewCreated has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
            super.onViewCreated(view, savedInstanceState)
    
            binding.topBar.setupWithNavController(findNavController())
    
    

      File ProfileFeedFragment.kt has 312 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package org.pixeldroid.app.profile
      
      import android.content.Intent
      import android.os.Bundle
      import android.view.LayoutInflater
      Severity: Minor
      Found in app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt - About 3 hrs to fix

        Class Converters has 28 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Converters {
            private val gson = Gson()
            private val formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME
        
            private val instantFormatter = DateTimeFormatter.ISO_INSTANT
        Severity: Minor
        Found in app/src/main/java/org/pixeldroid/app/utils/db/Converters.kt - About 3 hrs to fix

          Method onCreate has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              override fun onCreate(savedInstanceState: Bundle?) {
                  super.onCreate(savedInstanceState)
                  binding = ActivityEditProfileBinding.inflate(layoutInflater)
                  setContentView(binding.root)
                  setSupportActionBar(binding.topBar)
          Severity: Major
          Found in app/src/main/java/org/pixeldroid/app/profile/EditProfileActivity.kt - About 3 hrs to fix

            Method bind has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                fun bind(post: Status, lifecycleScope: LifecycleCoroutineScope, api: PixelfedAPI,
                         addCollection: Boolean = false, collection: Collection? = null, deleteFromCollection: Boolean = false
                ) {
            
                    if ((post.media_attachments?.size ?: 0) == 0){
            Severity: Major
            Found in app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt - About 3 hrs to fix

              File LoginActivity.kt has 273 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              package org.pixeldroid.app
              
              import android.content.Context
              import android.content.Intent
              import android.content.SharedPreferences
              Severity: Minor
              Found in app/src/main/java/org/pixeldroid/app/LoginActivity.kt - About 2 hrs to fix

                Method onCreate has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    override fun onCreate(savedInstanceState: Bundle?) {
                        super.onCreate(savedInstanceState)
                
                        val binding = ActivityAlbumBinding.inflate(layoutInflater)
                        setContentView(binding.root)
                Severity: Major
                Found in app/src/main/java/org/pixeldroid/app/posts/AlbumActivity.kt - About 2 hrs to fix

                  Method initAttributes has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private fun initAttributes() {
                          context.theme.obtainStyledAttributes(
                                  attributeSet,
                                  R.styleable.ImageCarousel,
                                  0,

                    Method onBindViewHolder has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                    Open

                            override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
                                val post = if(collections && user?.user_id == accountId && position == 0) null else getItem(if(collections && user?.user_id == accountId) position - 1 else position)
                    
                                post?.let {
                                    if(collections) {
                    Severity: Minor
                    Found in app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt - About 2 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 initListeners has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                    Open

                        private fun initListeners() {
                            recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
                                override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
                                    val position = currentPosition
                    
                    

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

                        private fun initListeners() {
                            recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
                                override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
                                    val position = currentPosition
                    
                    

                      Method onCreateDialog has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
                      Open

                          override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
                              val list: MutableList<String> = mutableListOf()
                              // IDE doesn't find it, but compiling works apparently?
                              resources.getXml(R.xml._generated_res_locale_config).use {
                                  var eventType = it.eventType
                      Severity: Minor
                      Found in app/src/main/java/org/pixeldroid/app/settings/SettingsActivity.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 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          override fun onCreate(savedInstanceState: Bundle?) {
                              super.onCreate(savedInstanceState)
                              binding = ActivityMediaviewerBinding.inflate(layoutInflater)
                              setContentView(binding.root)
                      
                      
                      Severity: Minor
                      Found in app/src/main/java/org/pixeldroid/app/posts/MediaViewerActivity.kt - About 1 hr to fix

                        Method onOptionsItemSelected has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            override fun onOptionsItemSelected(item: MenuItem): Boolean {
                                return when (item.itemId) {
                                    R.id.delete_collection -> {
                                        MaterialAlertDialogBuilder(this).apply {
                                            setMessage(R.string.delete_collection_warning)
                        Severity: Minor
                        Found in app/src/main/java/org/pixeldroid/app/profile/CollectionActivity.kt - About 1 hr to fix

                          Method onCreate has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                          Open

                              override fun onCreate(savedInstanceState: Bundle?) {
                                  super.onCreate(savedInstanceState)
                          
                                  val binding = ActivityAlbumBinding.inflate(layoutInflater)
                                  setContentView(binding.root)
                          Severity: Minor
                          Found in app/src/main/java/org/pixeldroid/app/posts/AlbumActivity.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

                          Severity
                          Category
                          Status
                          Source
                          Language