Showing 57 of 148 total issues
Method createView
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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
}
Method goTo
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun goTo(index: Int){
if((0 until uiState.value.imageList.size).contains(index)) {
_uiState.update { currentUiState ->
currentUiState.copy(
currentImage = index,
Method updateProgress
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun updateProgress(){
val currentItem = data?.getOrNull(currentPosition)
currentItem?.let {
Method newDirectMessage
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Open
override fun onScroll(
e1: MotionEvent?,
e2: MotionEvent,
distanceX: Float,
distanceY: Float
- Read upRead up
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
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
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" }
Method customTabsTutorial
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fun customTabsTutorial(){
lifecycleScope.launch {
var target =
(supportFragmentManager.findFragmentByTag("topsettingsfragment") as? SettingsFragment)?.scrollToArrangeTabs(5)
while (target == null) {
Method reportStatus
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private fun reportStatus(success: UploadState){
when (success) {
UploadState.initial -> {
binding.reportProgressBar.visibility = View.GONE
binding.reportButton.visibility = View.VISIBLE
Method initIndicator
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Open
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.delete_collection -> {
MaterialAlertDialogBuilder(this).apply {
setMessage(R.string.delete_collection_warning)
- Read upRead up
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
Open
fun bind(post: Status, lifecycleScope: LifecycleCoroutineScope, api: PixelfedAPI,
addCollection: Boolean = false, collection: Collection? = null, deleteFromCollection: Boolean = false
Method updateUserAccountDetails
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
suspend fun updateUserAccountDetails(username: String, displayName: String, avatarStatic: String, id: String, instanceUri: String)
Method composeBitmap
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
width: Int, height: Int,
numCompX: Int, numCompY: Int,
colors: Array<FloatArray>
Avoid too many return
statements within this method. Open
Open
return MediatorResult.Error(exception)
Avoid too many return
statements within this method. Open
Open
return MediatorResult.Error(exception)