DishDelish/dishdelish-app

View on GitHub

Showing 92 of 120 total issues

Method setupIngredientAutocomplete has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public void setupIngredientAutocomplete(AutoCompleteTextView ingredientAutoComplete, Map<String, Integer> idMap, IngredientAutocomplete apiService){
        ingredientAutoComplete.setThreshold(1);

        final BooleanWrapper optionSelected = new BooleanWrapper(false);
        ingredientAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {

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

                } else {
                    currentComment.decreaseLikes();
                    database.updateAsync(recipe)
                            .addOnSuccessListener(s -> {
                                // change background
    app/src/main/java/com/github/siela1915/bootcamp/CommentViewHolder.java on lines 109..129

    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 112.

    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

                    } else {
                        currentComment.increaseLikes();
                        database.updateAsync(recipe)
                                .addOnSuccessListener(arg -> {
                                    buttonView.setBackground(getDrawable(itemView.getContext(), R.drawable.ic_thumb_full));
    app/src/main/java/com/github/siela1915/bootcamp/CommentViewHolder.java on lines 130..153

    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 112.

    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 getNutritionFromIngredient has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public void getNutritionFromIngredient(int id, Ingredient ingredient, Map<Integer, Boolean> finishedMap, UploadCallback callback){
            //System.out.println(service.getNutrition(id, ingredient.getUnit().getValue(), API_KEY).request().url().toString());
    
            //To be able to get the nutrition correctly for a given unit, we need a naming convention for the units which I am not sure how to do
            //TODO give the users possible options of units once he chooses an ingredient?

      Method onCreateView has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              view = inflater.inflate(R.layout.fragment_upload_recipes, container, false);
      
      

        Method popUpDialogBuilder has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @SuppressLint("ResourceAsColor")
            private void popUpDialogBuilder(String[] items, boolean[] checksum, String title, List<Integer> selected, int filter){
                AlertDialog.Builder builder= new AlertDialog.Builder(getContext(),R.style.AlertDialogTheme);
                builder.setTitle(title);
                builder.setCancelable(false);

          Method filterLanguage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public static String filterLanguage(String input) {
                  if (input == null || input.isEmpty()) {
                      return input;
                  }
                  String s = filterLeetSpeach(input).toLowerCase().replaceAll("[^a-z]", " ");

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

              @Override
              public boolean equals(Object obj) {
                  if (obj instanceof Comment) {
                      if (likes != ((Comment)obj).likes
                              || !content.equals(((Comment)obj).content)) {

          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 onMapReady has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @SuppressLint("MissingPermission")
              @Override
              public void onMapReady(@NonNull GoogleMap googleMap) {
                  googleMap.setOnInfoWindowClickListener(this);
          
          

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

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    int position = getAdapterPosition();
                        Comment currentComment = adapter.getData().get(position);
                        if (isChecked) {

              Method getNearby has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public Task<List<Pair<String, Location>>> getNearby(Location location) {
                      FirebaseUser user = FirebaseInstanceManager.getAuth().getCurrentUser();
                      if (user == null) {
                          return Tasks.forException(new UserNotAuthenticatedException("User needs to be authenticated to store location"));
                      }

                Method onSignInResult has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private void onSignInResult(FirebaseAuthUIAuthenticationResult result) {
                        IdpResponse response = result.getIdpResponse();
                        if (result.getResultCode() == RESULT_OK) {
                            // Successfully signed in
                            FirebaseUser user = FirebaseInstanceManager.getAuth().getCurrentUser();

                  Method fetchRecipeList has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public List<String> fetchRecipeList(){
                          //String will represent the ID of the recipe, for now it's just the name
                          Map<String, Float> mapOfRecipes = new HashMap<>();
                  
                          for(Recipe r :allRecipes){

                    Method isStepValid has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public boolean isStepValid() {
                            for (int i = 0; i < stepListLinearLayout.getChildCount(); i++) {
                                if (stepListLinearLayout.getChildAt(i) instanceof ConstraintLayout) {
                                    ConstraintLayout step = (ConstraintLayout) stepListLinearLayout.getChildAt(i);
                                    if (step.getChildAt(0) instanceof TextInputLayout) {

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

                            @Override
                            public void handleMessage(Message msg) {
                                synchronized (CountDownTimerWithPause.this) {
                                    if (!paused) {
                                        final long millisLeft = stopTimeInFuture - getRealTime();

                    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

                            if (filterLanguage) {
                                String filtered = filterLanguage(comment.getContent());
                                if (comment.getReplies().size() == 0) {
                                    return new Comment(comment.getLikes(), filtered, new LinkedList<>());
                                }
                    app/src/main/java/com/github/siela1915/bootcamp/Tools/LanguageFilter.java on lines 455..465

                    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 84.

                    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

                            } else {
                                String filtered = filterSingleWords(comment.getContent());
                                if (comment.getReplies().size() == 0) {
                                    return new Comment(comment.getLikes(), filtered, new LinkedList<>());
                                }
                    app/src/main/java/com/github/siela1915/bootcamp/Tools/LanguageFilter.java on lines 445..455

                    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 84.

                    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 addIngredient has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public void addIngredient(Map<String, Integer> idMap, IngredientAutocomplete apiService, boolean offerable, List<String> prefill) {
                            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
                                final View ingredient = inflater.inflate(R.layout.recipe_ingredient_edittext, null, false);
                                ImageView removeIngredient = (ImageView) ingredient.findViewById(R.id.removeIngredient);
                                ImageView offerIngredient = (ImageView) ingredient.findViewById(R.id.offerIngredientItem);

                      Method filterComment has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public static Comment filterComment(Comment comment, boolean filterLanguage) {
                              if (filterLanguage) {
                                  String filtered = filterLanguage(comment.getContent());
                                  if (comment.getReplies().size() == 0) {
                                      return new Comment(comment.getLikes(), filtered, new LinkedList<>());

                      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 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
                        Severity
                        Category
                        Status
                        Source
                        Language