H-PixelDroid/PixelDroid

View on GitHub

Showing 148 of 148 total issues

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

    companion object {
        fun create(parent: ViewGroup): CollectionsViewHolder {
            val itemBinding = FragmentProfilePostsBinding.inflate(
                LayoutInflater.from(parent.context), parent, false
            )
app/src/main/java/org/pixeldroid/app/posts/feeds/uncachedFeeds/accountLists/AccountListFragment.kt on lines 103..110
app/src/main/java/org/pixeldroid/app/posts/feeds/uncachedFeeds/search/SearchHashtagFragment.kt on lines 126..133
app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt on lines 340..347
app/src/main/java/org/pixeldroid/app/profile/ProfilePostsRecyclerViewAdapter.kt on lines 14..21

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

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

    companion object {
        fun create(parent: ViewGroup): AccountViewHolder {
            val itemBinding = AccountListEntryBinding.inflate(
                LayoutInflater.from(parent.context), parent, false
            )
app/src/main/java/org/pixeldroid/app/posts/feeds/uncachedFeeds/search/SearchHashtagFragment.kt on lines 126..133
app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt on lines 242..249
app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt on lines 340..347
app/src/main/java/org/pixeldroid/app/profile/ProfilePostsRecyclerViewAdapter.kt on lines 14..21

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

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

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)

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

                            TapTarget.forView(targetCamera,
                                getString(R.string.story_tutorial_title),
                                getString(R.string.story_tutorial_explanation))
                                .transparentTarget(true)
                                .targetRadius(60),
            app/src/main/java/org/pixeldroid/app/settings/ArrangeTabsFragment.kt on lines 139..145

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

            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

                                                        TapTarget.forView(
                                                            hashtag,
                                                            getString(R.string.custom_feed_tutorial_title),
                                                            getString(R.string.custom_feed_tutorial_explanation)
                                                        )
            app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt on lines 78..82

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

            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

            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

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

                        UploadState.success -> {
                            binding.reportProgressBar.visibility = View.GONE
                            binding.reportButton.visibility = View.INVISIBLE
                            binding.reportSuccess.visibility = View.VISIBLE
                        }
            app/src/main/java/org/pixeldroid/app/posts/ReportActivity.kt on lines 53..57

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

            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

                        UploadState.initial -> {
                            binding.reportProgressBar.visibility = View.GONE
                            binding.reportButton.visibility = View.VISIBLE
                            binding.reportSuccess.visibility = View.INVISIBLE
                        }
            app/src/main/java/org/pixeldroid/app/posts/ReportActivity.kt on lines 58..62

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

            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

            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

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

                              postPreview.setOnClickListener {
                                  val intent = Intent(postPreview.context, CollectionActivity::class.java)
                                  intent.putExtra(CollectionActivity.COLLECTION_TAG, collection)
                                  postPreview.context.startActivity(intent)
                              }
                      app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt on lines 332..336

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

                      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 {
                                      val intent = Intent(postPreview.context, PostActivity::class.java)
                                      intent.putExtra(Status.POST_TAG, post)
                                      postPreview.context.startActivity(intent)
                                  }
                      app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt on lines 235..239

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

                      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

                                      while (target == null) {
                                          target = (supportFragmentManager.findFragmentByTag("topsettingsfragment") as? SettingsFragment)?.scrollToArrangeTabs(10)
                                          delay(100)
                                      }
                      app/src/main/java/org/pixeldroid/app/settings/SettingsActivity.kt on lines 154..157

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language