Showing 17 of 93 total issues
Method rating
has a Cognitive Complexity of 70 (exceeds 20 allowed). Consider refactoring. Open
private fun rating(sale: Sale){
bookDB = Database.bookDatabase(this)
val ratingBar: RatingBar = findViewById(R.id.sale_information_rating)
ratingBar.rating = 0f
- 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 FBSaleDatabase.kt
has 288 lines of code (exceeds 250 allowed). Consider refactoring. Open
package com.github.polybooks.database
import com.github.polybooks.core.*
import com.github.polybooks.database.SaleOrdering.*
import com.github.polybooks.utils.listOfFuture2FutureOfList
Method rating
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
private fun rating(sale: Sale){
bookDB = Database.bookDatabase(this)
val ratingBar: RatingBar = findViewById(R.id.sale_information_rating)
ratingBar.rating = 0f
Method onCreate
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_fill_sale)
bookDB = Database.bookDatabase(applicationContext)
Method getAll
has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring. Open
override fun getAll(): CompletableFuture<List<Sale>> {
return if (interests == null && title == null && isbn == null) { //In this case we should not look in the book database
doQueries(filterQuery(saleRef)).thenCompose { snapshotsToSales(it) }
.thenApply { order(it, ordering) }
} else {
- 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 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_signup)
auth = Firebase.auth
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_login)
val signInGoogleButton = findViewById<SignInButton>(R.id.sign_in_button)
Method filterQuery
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
//This functions computes the set of queries to execute in order to get the desired Sales.
//We need to return a set of queries because Firebase doesn't allow for more than one IN clause.
//Ergo, we need to do multiple queries.
private fun filterQuery(q: Query): List<Query> {
var queries = listOf(q)
Method parseBook
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
/**
* Function for internal use in OLBookDatabase. Takes the json of a book, and makes a Book from it.
* */
@RequiresApi(Build.VERSION_CODES.N)
private fun parseBook(jsonBook: JsonElement): Book {
Method scanBarcodes
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
// Inspired from the library guide : https://developers.google.com/ml-kit/vision/barcode-scanning/android#kotlin
@SuppressLint("UnsafeExperimentalUsageError")
private fun scanBarcodes(imageProxy: ImageProxy) {
val mediaImage = imageProxy.image
Method takePhoto
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
fun takePhoto(view: View) {
// TODO offer flash option and other quality of life upgrades
// Get a stable reference of the modifiable image capture use case
val imageCapture = imageCapture ?: return
Method setupNavbar
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
fun setupNavbar(
navBar: BottomNavigationView,
origin: Context,
selectedItem: Int = R.id.default_selected,
selectedListener: BottomNavigationView.OnNavigationItemSelectedListener? = null
Method setParametersButtons
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private fun setParametersButtons() {
setTextParameters()
mSortParameter = Parameter(
R.id.sale_sort_parameter,
Method getInternetPrice
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
fun getInternetPrice(isbn : ISBN): CompletableFuture<String> {
return CompletableFuture.supplyAsync {
val appId = "?key=1orhhq0s3nrtl4kf93r3"
val urlString = "https://booksrun.com/api/price/sell/$isbn$appId"
val url = URL(urlString)
- 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 addSale
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
fun addSale(bookISBN : ISBN,
seller : User,
price : Float,
condition : BookCondition,
state : SaleState,
Method addSale
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
bookISBN: ISBN,
seller: User,
price: Float,
condition: BookCondition,
state: SaleState,
Method scanBarcodes
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
// Inspired from the library guide : https://developers.google.com/ml-kit/vision/barcode-scanning/android#kotlin
@SuppressLint("UnsafeExperimentalUsageError")
private fun scanBarcodes(imageProxy: ImageProxy) {
val mediaImage = imageProxy.image
- 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"