Showing 57 of 148 total issues
Method initListeners
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private fun initListeners() {
recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
val position = currentPosition
Method onCreateDialog
has a Cognitive Complexity of 29 (exceeds 20 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
- 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 onCreateDialog
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val items = arrayOf(
Pair(R.string.feeds_tutorial, R.drawable.ic_home_white_24dp),
Pair(R.string.create_tutorial, R.drawable.photo_camera),
Pair(R.string.dm_tutorial, R.drawable.message),
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)
Method onCreateDialog
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
binding = LayoutTabsArrangeBinding.inflate(layoutInflater)
val itemCount = model.initTabsChecked()
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)
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)
- 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 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
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.
- 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 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)
- 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 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) {
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)
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)
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)
- 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 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)
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
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 -> {