Showing 20 of 26 total issues
Method addListenersToAppliedProjects
has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring. Open
private fun addListenersToAppliedProjects() {
appliedProjects.forEach {
candidatureDatabase.addListener(it) { _: ProjectId, list: List<Candidature> ->
val ownCandidatureThatChanged: Candidature? =
list.find { candidature -> candidature.userId == userId }
- 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
File FirebaseUserdataDatabase.kt
has 284 lines of code (exceeds 250 allowed). Consider refactoring. Open
package com.sdp13epfl2021.projmag.database.impl.firebase
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.google.firebase.firestore.DocumentReference
Class ProjectsListActivity
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
/**
* Displays a list of projects. User can filter based on various criteria and search by name.
*/
@AndroidEntryPoint
class ProjectsListActivity : AppCompatActivity() {
Method getProfile
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
override fun getProfile(
userID: String,
onSuccess: (profile: ImmutableProfile?) -> Unit,
onFailure: (Exception) -> Unit
) {
- 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 buildCopy
has 16 arguments (exceeds 5 allowed). Consider refactoring. Open
id: String = this.id,
name: String = this.name,
lab: String = this.lab,
authorId: String = this.authorId,
teacher: String = this.teacher,
Method build
has 16 arguments (exceeds 5 allowed). Consider refactoring. Open
id: String,
name: String,
lab: String,
authorId: String,
teacher: String,
Method getProfile
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun getProfile(
userID: String,
onSuccess: (profile: ImmutableProfile?) -> Unit,
onFailure: (Exception) -> Unit
) {
Method onCreate
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_profile_display)
val profile: ImmutableProfile? = intent.getParcelableExtra(MainActivity.profile)
Method invoke
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
/**
* Tells if the given project match the constraints
*
* @param project the project to check constraint
*
- 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)
setContentView(R.layout.activity_profile_page)
Method onActivityResult
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
/**
* This function is called after the user comes back
* from selecting a video from the file explorer
*/
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
Method buildFromMap
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
/**
* Build a project from the given map
*
* @param map : a map containing all fields of the project
* @param projectId : the id of the project
Method build
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
/**
* Function that allows create a Project
* returns a project wrapped in a success wrapper, or a failure with the explanation wrapped as a string
*
* @param id : project id from firebase
Method addCandidature
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
/**
* Load profile and cv for a particular candidature, then add the resulting candidature to the collection of candidatures if valid.
*
* @param candidatures a queue where candidature will be inserted.
* @param projectID the id of the project.
Method onBindViewHolder
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun onBindViewHolder(holder: CandidatureHolder, position: Int) {
val candidature = candidatures[position]
holder.firstnameView.text =
resources.getString(R.string.waiting_firstname, candidature.profile.firstName)
holder.lastnameView.text =
Method onCreate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.project_filter_settings)
// Update the view for this activity
Method loadUsersData
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private fun loadUsersData() {
try {
usersRootDir.listFiles()?.forEach { userDir ->
userDir.listFiles()?.forEach { file ->
file.parentFile?.name?.let { userID ->
Method onCreate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_user_type_choice)
val settings = getSharedPreferences(savedTypeChoice, Context.MODE_PRIVATE)
val editor = settings.edit()
Method getProjectsFromTags
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
override fun getProjectsFromTags(
tags: List<String>,
onSuccess: (List<ImmutableProject>) -> Unit,
onFailure: (Exception) -> Unit
) {
- 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 loadUsersData
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
private fun loadUsersData() {
try {
usersRootDir.listFiles()?.forEach { userDir ->
userDir.listFiles()?.forEach { file ->
file.parentFile?.name?.let { userID ->
- 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"