H-PixelDroid/PixelDroid

View on GitHub

Showing 117 of 117 total issues

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

        if ((post.media_attachments?.size ?: 0) == 0){
            //No media in this post, so put a little icon there
            postPreview.scaleX = 0.3f
            postPreview.scaleY = 0.3f
            Glide.with(postPreview).load(R.drawable.ic_comment_empty).into(postPreview)
app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt on lines 216..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 133.

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

        if (collection.post_count == 0){
            //No media in this collection, so put a little icon there
            postPreview.scaleX = 0.3f
            postPreview.scaleY = 0.3f
            Glide.with(postPreview).load(R.drawable.ic_comment_empty).into(postPreview)
app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt on lines 261..268

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

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

      Method load has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          override suspend fun load(params: LoadParams<String>): LoadResult<String, Account> {
              val position = params.key
              return try {
                  val response =
                  // Pixelfed and Mastodon don't implement this in the same fashion. Pixelfed uses

        Method onCreateDialog has 37 lines of code (exceeds 25 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

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

                      R.id.remove_post_collection -> {
                          val intent = Intent(this, CollectionActivity::class.java)
                          intent.putExtra(COLLECTION_TAG, collection)
                          intent.putExtra(DELETE_FROM_COLLECTION_TAG, true)
                          startActivity(intent)
          app/src/main/java/org/pixeldroid/app/profile/CollectionActivity.kt on lines 122..128

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

          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

                      R.id.add_post_collection -> {
                          val intent = Intent(this, CollectionActivity::class.java)
                          intent.putExtra(COLLECTION_TAG, collection)
                          intent.putExtra(ADD_COLLECTION_TAG, true)
                          startActivity(intent)
          app/src/main/java/org/pixeldroid/app/profile/CollectionActivity.kt on lines 129..135

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

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

              override fun onCreate(savedInstanceState: Bundle?) {
                  super.onCreate(savedInstanceState)
                  binding = ActivityTrendingBinding.inflate(layoutInflater)
                  setContentView(binding.root)
                  setSupportActionBar(binding.topBar)

            Method onBindViewHolder has 35 lines of code (exceeds 25 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 1 hr to fix

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

                  private fun authenticate(code: String?) {
              
                      // Get previous values from preferences
                      val domain = preferences.getString("domain", "") as String
                      val clientId = preferences.getString("clientID", "") as String
              Severity: Minor
              Found in app/src/main/java/org/pixeldroid/app/LoginActivity.kt - About 1 hr to fix

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

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

                  Method registerAppToServer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private fun registerAppToServer(normalizedDomain: String) {
                  
                          if(!validDomain(normalizedDomain)) return failedRegistration(getString(R.string.invalid_domain))
                  
                          hideKeyboard()
                  Severity: Minor
                  Found in app/src/main/java/org/pixeldroid/app/LoginActivity.kt - About 1 hr to fix

                    Method registerAppToServer has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                    Open

                        private fun registerAppToServer(normalizedDomain: String) {
                    
                            if(!validDomain(normalizedDomain)) return failedRegistration(getString(R.string.invalid_domain))
                    
                            hideKeyboard()
                    Severity: Minor
                    Found in app/src/main/java/org/pixeldroid/app/LoginActivity.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 draw has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        override fun draw(canvas: Canvas) {
                            paint.strokeWidth = 0.5f * bounds.height()
                            val y = 0.5f * bounds.height()
                            val sectionWidth = 1.0f * bounds.width() / numStories
                            val sectionPadding = 0.03f * sectionWidth
                    Severity: Minor
                    Found in app/src/main/java/org/pixeldroid/app/stories/StoryProgress.kt - About 1 hr to fix

                      Method load has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          override suspend fun load(loadType: LoadType, state: PagingState<Int, Notification>): MediatorResult {
                      
                              val maxId = when (loadType) {
                                  LoadType.REFRESH -> null
                                  LoadType.PREPEND -> {

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

                            companion object {
                                fun create(parent: ViewGroup): ProfilePostViewHolder {
                                    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 242..249
                        app/src/main/java/org/pixeldroid/app/profile/ProfileFeedFragment.kt on lines 340..347

                        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): ProfilePostsViewHolder {
                                    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 242..249
                        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): HashTagViewHolder {
                                    val itemBinding = FragmentTagsBinding.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/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

                        Severity
                        Category
                        Status
                        Source
                        Language