H-PixelDroid/PixelDroid

View on GitHub

Showing 148 of 148 total issues

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

                                        TapTarget.forView(findViewById(R.id.tv_caption),
                                            getString(R.string.media_description_tutorial_title),
                                            getString(R.string.media_description_tutorial_explanation))
                                            .transparentTarget(true)
                                            .targetRadius(60),
app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt on lines 90..94
app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt on lines 121..127
app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt on lines 177..181

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

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

                                                        TapTarget.forView(findViewById(R.id.post_creation_next_button),
                                                            getString(
                                                                R.string.picture_tutorial_title
                                                            ),
                                                            getString(R.string.picture_tutorial_explanation))
app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt on lines 90..94
app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt on lines 102..106
app/src/main/java/org/pixeldroid/app/postCreation/PostCreationActivity.kt on lines 177..181

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

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

Method createEdgeEffect has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
Open

    override fun createEdgeEffect(recyclerView: RecyclerView, direction: Int): EdgeEffect {

        return object : EdgeEffect(recyclerView.context) {

            // A reference to the [SpringAnimation] for this RecyclerView used to bring the item back after the over-scroll effect.

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

            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 onBindViewHolder has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
Open

        @SuppressLint("ClickableViewAccessibility")
        override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
            val textView: MaterialButton = holder.itemView.findViewById(R.id.textView)
            val checkBox: MaterialCheckBox = holder.itemView.findViewById(R.id.checkBox)
            val dragHandle: ImageView = holder.itemView.findViewById(R.id.dragHandle)

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

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

                    db.withTransaction {
                        // Clear table in the database
                        if (loadType == LoadType.REFRESH) {
                            db.notificationDao().clearFeedContent(user.user_id, user.instance_uri)
                        }
        app/src/main/java/org/pixeldroid/app/directmessages/DirectMessagesRemoteMediator.kt on lines 73..79

        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

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

                    db.withTransaction {
                        // Clear table in the database
                        if (loadType == LoadType.REFRESH) {
                            db.directMessagesDao().clearFeedContent(user.user_id, user.instance_uri)
                        }
        app/src/main/java/org/pixeldroid/app/posts/feeds/cachedFeeds/notifications/NotificationsRemoteMediator.kt on lines 67..73

        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

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

            override suspend fun load(loadType: LoadType, state: PagingState<Int, Conversation>): MediatorResult {
                try {
                    val user = db.userDao().getActiveUser()
                        ?: return MediatorResult.Error(NullPointerException("No active user exists"))
                    val api = apiHolder.api ?: apiHolder.setToCurrentUser()

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

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

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

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

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

                override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
                    sharedPreferences?.let {
                        when (key) {
                            "theme" -> {
                                setThemeFromPreferences(it, resources)
            Severity: Minor
            Found in app/src/main/java/org/pixeldroid/app/settings/SettingsActivity.kt - About 1 hr to fix

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language