DishDelish/dishdelish-app

View on GitHub

Showing 92 of 120 total issues

Method onInfoWindowClick has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    public void onInfoWindowClick(@NonNull Marker marker) {
        Pair<String, Ingredient> offer = offers.get(marker);
        FirebaseUser user = FirebaseInstanceManager.getAuth().getCurrentUser();

    Method onCheckedChanged has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
    
                // Add the recipe to favorites
    Severity: Minor
    Found in app/src/main/java/com/github/siela1915/bootcamp/RecipeActivity.java - About 1 hr to fix

      Method setCommentContents has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void setCommentContents(RecyclerView commentsList) {
      
              commentsList.setLayoutManager(new LinearLayoutManager(this));
              for(Comment c : recipe.comments){
                  c.setContent(LanguageFilter.filterLanguage(c.getContent()));
      Severity: Minor
      Found in app/src/main/java/com/github/siela1915/bootcamp/RecipeActivity.java - About 1 hr to fix

        Method onCreate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_recipe);
        
        
        Severity: Minor
        Found in app/src/main/java/com/github/siela1915/bootcamp/RecipeActivity.java - About 1 hr to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      database.addFavorite(recipe.uniqueKey).addOnSuccessListener(arg -> {
                          // Show a success message to the user
                          Toast.makeText(this, "Recipe added to favorites", Toast.LENGTH_SHORT).show();
          
                          //change background
          app/src/main/java/com/github/siela1915/bootcamp/RecipeActivity.java on lines 327..340

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      database.removeFavorite(recipe.uniqueKey).addOnSuccessListener(s -> {
          
                          // display success message
                          Toast.makeText(this, "Recipe removed from favorites", Toast.LENGTH_SHORT).show();
          
          
          app/src/main/java/com/github/siela1915/bootcamp/RecipeActivity.java on lines 301..312

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              public static CuisineType getDominantCuisine(List<Recipe> ls) {
                  int[] arr = new int[CuisineType.values().length];
                  for (Recipe elem : ls) {
                      elem.getCuisineTypes().forEach(cuisine -> ++arr[cuisine]);
                  }
          app/src/main/java/com/github/siela1915/bootcamp/Tools/Utilities.java on lines 89..95
          app/src/main/java/com/github/siela1915/bootcamp/Tools/Utilities.java on lines 103..109

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 62.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              public static DietType getDominantDiet(List<Recipe> ls) {
                  int[] arr = new int[DietType.values().length];
                  for (Recipe elem : ls) {
                      elem.getDietTypes().forEach(diet -> ++arr[diet]);
                  }
          app/src/main/java/com/github/siela1915/bootcamp/Tools/Utilities.java on lines 89..95
          app/src/main/java/com/github/siela1915/bootcamp/Tools/Utilities.java on lines 117..123

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 62.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              public static AllergyType getDominantAllergy(List<Recipe> ls) {
                  int[] arr = new int[AllergyType.values().length];
                  for (Recipe elem : ls) {
                      elem.getAllergyTypes().forEach(allergy -> ++arr[allergy]);
                  }
          app/src/main/java/com/github/siela1915/bootcamp/Tools/Utilities.java on lines 103..109
          app/src/main/java/com/github/siela1915/bootcamp/Tools/Utilities.java on lines 117..123

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 62.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Avoid deeply nested control flow statements.
          Open

                                                  if (offer.getUnit().getValue() >= asked.getUnit().getValue()) {
                                                      color = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN);
                                                  } else {
                                                      color = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE);
                                                  }
          Severity: Major
          Found in app/src/main/java/com/github/siela1915/bootcamp/NearbyHelpFragment.java - About 45 mins to fix

            Method filterSingleWords has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public static String filterSingleWords(String input) {
                    if (input == null || input.isEmpty()) {
                        return input;
                    }
                    //Don't forget to filter out any punctuation or other symbols

            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 openHelp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                private void openHelp() {
                    Bundle extras = getIntent().getExtras();
                    navigationView.setCheckedItem(R.id.menuItem_help);
                    Intent intent = new Intent(this, MainHomeActivity.class);
                    if (extras != null) {
            Severity: Minor
            Found in app/src/main/java/com/github/siela1915/bootcamp/MainHomeActivity.java - About 45 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public CommentAdapter(Context context, List<Comment> comments, Recipe recipe) {
                    this.context = context;
                    this.comments = comments;
                    this.recipe = recipe;
            
            
            app/src/main/java/com/github/siela1915/bootcamp/ReplyAdapter.java on lines 25..31

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 54.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public ReplyAdapter(Context context, List<Comment> replies, Comment parent){
                    this.context = context;
                    this.replies = replies;
                    this.parent = parent;
            
            
            app/src/main/java/com/github/siela1915/bootcamp/CommentAdapter.java on lines 28..34

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 54.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                        || (DietType.fromIntList(diets)).stream()
                                .distinct()
                                .filter(x -> (DietType.fromIntList(r.dietTypes)).stream().anyMatch(y -> y.equals(x)))
                                .toArray().length > 0
            app/src/main/java/com/github/siela1915/bootcamp/Labelling/RecipeFetcher.java on lines 62..65

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                        || (AllergyType.fromIntList(allergies)).stream()
                                .distinct()
                                .filter(x -> (AllergyType.fromIntList(r.allergyTypes)).stream().anyMatch(y -> y.equals(x)))
                                .toArray().length > 0
            app/src/main/java/com/github/siela1915/bootcamp/Labelling/RecipeFetcher.java on lines 66..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 50.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method sendRemoteNotification has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                static public Task<Void> sendRemoteNotification(Context context, String userId, String title, String body, Map<String, String> data) {

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      userDb.getUser(replies.get(position).getUserId()).addOnSuccessListener(user -> {
                          holder.userName.setText(user.getDisplayName());
                          new DownloadImageTask(holder.photo).execute(user.getPhotoUrl());
                      });
              app/src/main/java/com/github/siela1915/bootcamp/CommentAdapter.java on lines 49..52

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 46.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                      userDb.getUser(comments.get(position).getUserId()).addOnSuccessListener(user -> {
                          holder.userName.setText(user.getDisplayName());
                          new DownloadImageTask(holder.photo).execute(user.getPhotoUrl());
                      });
              app/src/main/java/com/github/siela1915/bootcamp/ReplyAdapter.java on lines 53..56

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 46.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Method getIngredients has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public List<Ingredient> getIngredients() {
                      ArrayList<Ingredient> ingredients = new ArrayList<Ingredient>();
                      for (int i = 0; i < ingredientLinearLayout.getChildCount(); i++) {
                          if (ingredientLinearLayout.getChildAt(i) instanceof ConstraintLayout) {
                              ConstraintLayout step = (ConstraintLayout) ingredientLinearLayout.getChildAt(i);

              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