CultureQuestORG/SDP2023

View on GitHub

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());

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 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);
Severity: Minor
Found in app/src/main/java/ch/epfl/culturequest/utils/CustomSnackbar.java - About 1 hr to fix

    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":
    Severity: Minor
    Found in app/src/main/java/ch/epfl/culturequest/social/ScanBadge.java - About 1 hr to fix

      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);
      Severity: Minor
      Found in app/src/main/java/ch/epfl/culturequest/ui/SightseeingActivity.java - About 1 hr to fix

        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 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 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)) {
            Severity: Minor
            Found in app/src/main/java/ch/epfl/culturequest/SettingsActivity.java - About 1 hr to fix

              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)
              Severity: Minor
              Found in app/src/main/java/ch/epfl/culturequest/database/Database.java - About 1 hr to fix

                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() {
                Severity: Minor
                Found in app/src/main/java/ch/epfl/culturequest/database/Database.java - About 1 hr to fix

                  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");
                  Severity: Minor
                  Found in app/src/main/java/ch/epfl/culturequest/SignUpActivity.java - About 1 hr to fix

                    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());
                    Severity: Minor
                    Found in app/src/main/java/ch/epfl/culturequest/SettingsActivity.java - About 1 hr to fix

                      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;
                      Severity: Minor
                      Found in app/src/main/java/ch/epfl/culturequest/social/PictureAdapter.java - About 1 hr to fix

                        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) {
                        Severity: Minor
                        Found in app/src/main/java/ch/epfl/culturequest/database/Database.java - About 55 mins to fix

                        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) {
                        Severity: Minor
                        Found in app/src/main/java/ch/epfl/culturequest/utils/CropUtils.java - About 55 mins to fix

                        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) {
                        Severity: Minor
                        Found in app/src/main/java/ch/epfl/culturequest/utils/CropUtils.java - About 45 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return null;
                          Severity: Major
                          Found in app/src/main/java/ch/epfl/culturequest/SignUpActivity.java - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return Authenticator.signIn(this);
                            Severity: Major
                            Found in app/src/main/java/ch/epfl/culturequest/SignUpActivity.java - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return null;
                              Severity: Major
                              Found in app/src/main/java/ch/epfl/culturequest/SignUpActivity.java - About 30 mins to fix

                                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

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language