H-PixelDroid/PixelDroid

View on GitHub

Showing 57 of 148 total issues

Method createView has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    fun createView(inflater: LayoutInflater, container: ViewGroup?,
                   savedInstanceState: Bundle?, reverseLayout: Boolean = false): ConstraintLayout {
        super.onCreateView(inflater, container, savedInstanceState)

        binding = FragmentFeedBinding.inflate(layoutInflater)

    Method authenticate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override fun authenticate(route: Route?, response: Response): Request? {
    
            if (response.responseCount() > 3) {
                return null // Give up, we've already failed to authenticate a couple times
            }
    Severity: Minor
    Found in app/src/main/java/org/pixeldroid/app/utils/di/APIModule.kt - About 1 hr to fix

      Method goTo has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private fun goTo(index: Int){
              if((0 until uiState.value.imageList.size).contains(index)) {
                  _uiState.update { currentUiState ->
                      currentUiState.copy(
                          currentImage = index,
      Severity: Minor
      Found in app/src/main/java/org/pixeldroid/app/stories/StoriesViewModel.kt - About 1 hr to fix

        Method updateProgress has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private fun updateProgress(){
        
                val currentItem = data?.getOrNull(currentPosition)
        
                currentItem?.let {

          Method newDirectMessage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private fun newDirectMessage() {
                  val newDmDialogBinding =
                      NewDmDialogBinding.inflate(LayoutInflater.from(this))
          
                  MaterialAlertDialogBuilder(this)

            Method onScroll has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
            Open

                    override fun onScroll(
                        e1: MotionEvent?,
                        e2: MotionEvent,
                        distanceX: Float,
                        distanceY: Float
            Severity: Minor
            Found in app/src/main/java/org/pixeldroid/app/posts/NestedScrollableHost.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 onCreateView has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @OptIn(ExperimentalPagingApi::class)
                override fun onCreateView(
                    inflater: LayoutInflater, container: ViewGroup?,
                    savedInstanceState: Bundle?
                ): View? {

              Method decode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private fun decode(blurHash: String?, width: Int?, height: Int?, punch: Float = 1f): Bitmap? {
                      if (blurHash == null || width == null || height == null || blurHash.length < 6) {
                          return null
                      }
                      require(width > 0) { "Width must be greater than zero" }
              Severity: Minor
              Found in app/src/main/java/org/pixeldroid/app/utils/BlurHashDecoder.kt - About 1 hr to fix

                Method customTabsTutorial has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    fun customTabsTutorial(){
                        lifecycleScope.launch {
                            var target =
                                (supportFragmentManager.findFragmentByTag("topsettingsfragment") as? SettingsFragment)?.scrollToArrangeTabs(5)
                            while (target == null) {
                Severity: Minor
                Found in app/src/main/java/org/pixeldroid/app/settings/SettingsActivity.kt - About 1 hr to fix

                  Method reportStatus has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private fun reportStatus(success: UploadState){
                          when (success) {
                              UploadState.initial -> {
                                  binding.reportProgressBar.visibility = View.GONE
                                  binding.reportButton.visibility = View.VISIBLE
                  Severity: Minor
                  Found in app/src/main/java/org/pixeldroid/app/posts/ReportActivity.kt - About 1 hr to fix

                    Method initIndicator has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private fun initIndicator() {
                            // If no custom indicator added, then default indicator will be shown.
                            if (indicator == null) {
                                indicator = binding.indicator
                                isBuiltInIndicator = true

                      Method onOptionsItemSelected has a Cognitive Complexity of 24 (exceeds 20 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 55 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 bind has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          fun bind(post: Status, lifecycleScope: LifecycleCoroutineScope, api: PixelfedAPI,
                                   addCollection: Boolean = false, collection: Collection? = null, deleteFromCollection: Boolean = false
                      Severity: Minor
                      Found in app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt - About 45 mins to fix

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

                            suspend fun updateUserAccountDetails(username: String, displayName: String, avatarStatic: String, id: String, instanceUri: String)
                        Severity: Minor
                        Found in app/src/main/java/org/pixeldroid/app/utils/db/dao/UserDao.kt - About 35 mins to fix

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

                                      width: Int, height: Int,
                                      numCompX: Int, numCompY: Int,
                                      colors: Array<FloatArray>
                          Severity: Minor
                          Found in app/src/main/java/org/pixeldroid/app/utils/BlurHashDecoder.kt - About 35 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return MediatorResult.Error(exception)

                              Avoid too many return statements within this method.
                              Open

                                          return MediatorResult.Error(exception)
                                Severity
                                Category
                                Status
                                Source
                                Language