jumaallan/AndelaCryptoApp

View on GitHub
app/src/main/java/com/androidstudy/andelatrackchallenge/models/Country.java

Summary

Maintainability
C
7 hrs
Test Coverage

Method getFlagRes has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @DrawableRes
    public int getFlagRes() {
        switch (code) {
            case "USD":
                return R.drawable.flag_us;

    Method equals has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
    
    

    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

            if (country.ethStatus != ethStatus) return false;

      Avoid too many return statements within this method.
      Open

              return code.equals(country.code);

        Avoid too many return statements within this method.
        Open

                if (country.btcStatus != btcStatus) return false;

          Avoid too many return statements within this method.
          Open

                  if (refreshedAt != country.refreshedAt) return false;

            Avoid too many return statements within this method.
            Open

                    if (Float.compare(country.eth, eth) != 0) return false;

              Avoid too many return statements within this method.
              Open

                      if (!name.equals(country.name)) return false;

                Avoid too many return statements within this method.
                Open

                        if (!country.isFavorite == isFavorite) return false;

                  Avoid too many return statements within this method.
                  Open

                          if (!currency.equals(country.currency)) return false;

                    There are no issues that match your filters.

                    Category
                    Status