DishDelish/dishdelish-app

View on GitHub

Showing 56 of 120 total issues

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

    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) {

      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

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

          public static FirebaseAuth getAuth() {
              FirebaseAuth auth = FirebaseAuth.getInstance();
      
              if (emulator) {
                  try {

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

          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              askLocationPermission();
              askNotificationPermission();
      Severity: Minor
      Found in app/src/main/java/com/github/siela1915/bootcamp/NearbyHelpFragment.java - About 35 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

      Avoid too many return statements within this method.
      Open

              return false;
      Severity: Major
      Found in app/src/main/java/com/github/siela1915/bootcamp/Recipes/Comment.java - About 30 mins to fix

        Method onSignInResult has a Cognitive Complexity of 6 (exceeds 5 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();

        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 6 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public boolean equals(Object obj) {
                if (obj instanceof Utensils) {
                    for (String u : ((Utensils) obj).utensils) {
                        if (!utensils.contains(u)) {
        Severity: Minor
        Found in app/src/main/java/com/github/siela1915/bootcamp/Recipes/Utensils.java - About 25 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 addIngredient has a Cognitive Complexity of 6 (exceeds 5 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);

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

            public List<Integer> getOfferable() {
                ArrayList<Integer> ingredients = new ArrayList<>();
                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

        Method getSteps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public List<String> getSteps() {
                ArrayList<String> steps = new ArrayList<String>();
                for (int i = 0; i < stepListLinearLayout.getChildCount(); i++) {
                    if (stepListLinearLayout.getChildAt(i) instanceof ConstraintLayout) {
                        ConstraintLayout step = (ConstraintLayout) stepListLinearLayout.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

        Method fetchRecipeList has a Cognitive Complexity of 6 (exceeds 5 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){

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

            public void transformPage(View view, float position) {
                int pageWidth = view.getWidth();
                int pageHeight = view.getHeight();
        
                if (position < -1 || position > 1) { // [-Infinity,-1)

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

            private List<Integer> getTypes(LinearLayout typeLayout, Object[] typeValues) {
                ArrayList<Integer> types = new ArrayList<Integer>();
                for (int i = 0; i < typeLayout.getChildCount(); i++) {
                    if (typeLayout.getChildAt(i) instanceof ConstraintLayout) {
                        ConstraintLayout type = (ConstraintLayout) typeLayout.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