H-PixelDroid/PixelDroid

View on GitHub

Showing 45 of 117 total issues

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

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

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

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

                            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 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 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 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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language