Showing 39 of 57 total issues
File Database.java
has 870 lines of code (exceeds 250 allowed). Consider refactoring. Open
package ch.epfl.culturequest.database;
import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
Database
has 83 methods (exceeds 20 allowed). Consider refactoring. Open
public class Database {
private static final FirebaseDatabase databaseInstance = FirebaseDatabase.getInstance();
private static boolean isEmulatorOn = false;
public static void setPersistenceEnabled() {
Method getDeviceLocation
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
private void getDeviceLocation() {
/*
* Get the best and most recent location of the device, which may be null in rare
* cases when a location is not available.
*/
- 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 PictureAdapter.java
has 338 lines of code (exceeds 250 allowed). Consider refactoring. Open
package ch.epfl.culturequest.social;
import static ch.epfl.culturequest.social.RarityLevel.getRarityLevel;
import android.animation.Animator;
Profile
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
public class Profile extends Observable {
private String uid, name, username, email, phoneNumber;
private String profilePicture;
private Integer score;
Method onLocationResult
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void onLocationResult(@NonNull LocationResult result) {
super.onLocationResult(result);
if (result != null) {
for (Location location : result.getLocations()) {
- 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 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidUtils.removeStatusBar(getWindow());
Authenticator.checkIfUserIsLoggedIn(this);
File TournamentManagerApi.java
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
package ch.epfl.culturequest.backend.tournament.apis;
import static androidx.test.InstrumentationRegistry.getTargetContext;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static ch.epfl.culturequest.backend.tournament.apis.SeedApi.generateOrFetchSeedThenStore;
Method onBindViewHolder
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void onBindViewHolder(@NonNull PictureViewHolder holder, int position) {
Post post = pictures.get(position);
String pictureUrl = post.getImageUrl();
Method onCreate
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_art_description_display);
findViewById(R.id.back_button).setOnClickListener(view -> onBackPressed());
Method handleLike
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void handleLike(@NonNull PictureViewHolder holder, Post post) {
if (post.getUid().equals(Profile.getActiveProfile().getUid())) {
holder.like.setVisibility(View.GONE);
return;
}
Method getOptimalPromptFieldName
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private String getOptimalPromptFieldName(String missingFieldName, BasicArtDescription.ArtType artType){
String promptFieldName = "";
switch (missingFieldName) {
Method getOptimalPromptFieldName
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private String getOptimalPromptFieldName(String missingFieldName, BasicArtDescription.ArtType artType){
String promptFieldName = "";
switch (missingFieldName) {
- 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 recoverPotentialMissesAndGetScore
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private CompletableFuture<BasicArtDescription> recoverPotentialMissesAndGetScore(BasicArtDescription incompleteDescription, ArtRecognition recognizedArt, RecoveryState recoveryState, int tryCount) {
OpenAIDescriptionApi openAIDescriptionApi = new OpenAIDescriptionApi(service);
CompletableFuture<Integer> score = openAIDescriptionApi.getScore(recognizedArt);
Method display_profile
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void display_profile(String uid) {
if (!activeProfile.getUid().equals(uid)) {
Database.getProfile(uid).whenComplete((selectedProfile, e) -> {
this.selectedProfile.setValue(selectedProfile);
username.setValue(selectedProfile.getUsername());
Method onCreate
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Authenticator.checkIfUserIsLoggedIn(this);
Method getNullFields
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private ArrayList<String> getNullFields(BasicArtDescription basicArtDescription, RecoveryState recoveryState) {
ArrayList<String> missingFields = new ArrayList<>();
// Get all declared fields (including private ones)
- 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 createProfile
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void createProfile(View view) {
//check if username is valid
if (setProblemHintTextIfAny(textView)) return;
String username = textView.getText().toString();
setDefaultPicIfNoneSelected();
Method signIn
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static CompletableFuture<String> signIn(ComponentActivity activity) {
CompletableFuture<String> future = new CompletableFuture<>();
if (getCurrentUser() == null) {
if (hasConnection(activity)) {
signInLauncher.launch(signInIntent());
Method updateLeaderboard
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void updateLeaderboard() {
String currentUserUid = activeProfile.getUid();
// retrieve the current user's information to be displayed in the leaderboard
currentUsername.setValue(activeProfile.getUsername());