Showing 39 of 57 total issues
Method onCreate
has a Cognitive Complexity of 11 (exceeds 5 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());
- 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 fromString
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static City fromString(String s) {
switch (s.toUpperCase()) {
case "BARCELONA":
return BARCELONA;
case "BERLIN":
Method showCustomSnackbar
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void showCustomSnackbar(String message, int imageResourceName, View rootView, Function<Void, Void> callback) {
// Inflate custom Snackbar layout
LayoutInflater inflater = LayoutInflater.from(rootView.getContext());
View customView = inflater.inflate(R.layout.custom_snackbar, null);
Method getWikipediaPageHtml
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private CompletableFuture<String> getWikipediaPageHtml(ArtRecognition recognizedArt) {
String wikipediaSearchUrl = wikipediaBaseUrl + recognizedArt.getArtName();
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
Method onCreate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressLint({"SetTextI18n", "ResourceAsColor"})
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Authenticator.checkIfUserIsLoggedIn(this);
Method sendNotification
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static List<CompletableFuture<AtomicBoolean>> sendNotification(String uid, PushNotification notification) {
List<CompletableFuture<AtomicBoolean>> futures = new ArrayList<>();
// add notification to database first
Database.addNotification(uid, notification);
Method changeFollow
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static CompletableFuture<Follows> changeFollow(String follower, String followed, boolean follow) {
CompletableFuture<Follows> future = new CompletableFuture<>();
DatabaseReference followsRef = databaseInstance.getReference("follows").child(follower);
followsRef.runTransaction(new Transaction.Handler() {
Method UpdateProfile
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void UpdateProfile(View v) {
EspressoIdlingResource.increment();
// Check if the username is valid
if (setProblemHintTextIfAny(username)) {
Method signUp
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressLint("SetTextI18n")
public void signUp(View v) {
String pw = password.getText().toString();
if (!hasDigit(pw)) {
issues.setText("Password must contain at least 1 digit");
Method getTopNFriendsProfiles
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static CompletableFuture<List<Profile>> getTopNFriendsProfiles(int n) {
DatabaseReference usersRef = databaseInstance.getReference("users");
CompletableFuture<List<Profile>> future = new CompletableFuture<>();
Profile.getActiveProfile().retrieveFriends().thenAccept(friends -> {
//the list of profiles to return (the top n profiles)
Method onCreate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
AndroidUtils.removeStatusBar(getWindow());
Method flip
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void flip(Context context, View visibleView, View inVisibleView) {
isFlipping = true;
visibleView.setVisibility(View.VISIBLE);
float scale = context.getResources().getDisplayMetrics().density;
float cameraDist = 8000 * scale;
Method handler
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static Transaction.Handler handler(CompletableFuture<Post> future, String UId, boolean add) {
return new Transaction.Handler() {
@NonNull
@Override
public Transaction.Result doTransaction(@NonNull MutableData mutableData) {
- 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 manageCropFlow
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static void manageCropFlow(int requestCode, int resultCode, Intent data, Activity activity, Function<Uri, Void> displayProfilePic, View rootView) {
// handle the result of the crop activity
if (resultCode == RESULT_OK && requestCode == UCrop.REQUEST_CROP) {
final Uri resultUri = UCrop.getOutput(data);
if (resultUri != null) {
- 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 manageCropFlow
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static void manageCropFlow(int requestCode, int resultCode, Intent data, Activity activity, Function<Uri, Void> displayProfilePic, View rootView) {
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return Authenticator.signIn(this);
Avoid too many return
statements within this method. Open
return null;
Method handleTournaments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static CompletableFuture<Void> handleTournaments(Context context) {
currentContext = context;
if (tournamentRemainingTime() == 0) { // A tournament has never been scheduled yet - first time the app is launched
- 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"