Nick9500/ministocks

View on GitHub
src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java

Summary

Maintainability
C
1 day
Test Coverage

File PortfolioStockRepository.java has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 The MIT License

 Copyright (c) 2013 Nitesh Patel http://niteshpatel.github.io/ministocks

Severity: Minor
Found in src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java - About 3 hrs to fix

    PortfolioStockRepository has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class PortfolioStockRepository {
        public static final String PORTFOLIO_JSON = "portfolioJson";
        public static final String WIDGET_JSON = "widgetJson";
        private static final HashMap<String, PortfolioStock> mPortfolioStocks = new HashMap<>();
        private static boolean mDirtyPortfolioStockMap = true;
    Severity: Minor
    Found in src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java - About 3 hrs to fix

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

          HashMap<String, PortfolioStock> getStocks() {
              if (!isDirtyPortfolioStockMap()) {
                  return mPortfolioStocks;
              }
              mPortfolioStocks.clear();
      Severity: Minor
      Found in src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java - About 1 hr to fix

        Method getStocks has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            HashMap<String, PortfolioStock> getStocks() {
                if (!isDirtyPortfolioStockMap()) {
                    return mPortfolioStocks;
                }
                mPortfolioStocks.clear();
        Severity: Minor
        Found in src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java - About 1 hr 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 updateStock has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public void updateStock(String symbol, String price, String date, String quantity,
                                    String limitHigh, String limitLow, String customDisplay) {
        Severity: Major
        Found in src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java - About 50 mins to fix

          Method populateDisplayTotalChange has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private void populateDisplayTotalChange(NumberFormat numberFormat, String symbol, PortfolioStock stock, Map<String, String> itemInfo, String currentPrice, String buyPrice) {
          Severity: Minor
          Found in src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java - About 45 mins to fix

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

                private void populateDisplayHoldingValue(NumberFormat numberFormat, String symbol, PortfolioStock stock, Map<String, String> itemInfo, String currentPrice) {
            Severity: Minor
            Found in src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java - About 35 mins to fix

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

                  private void populateDisplayLastChange(NumberFormat numberFormat, String symbol, StockQuote quote, PortfolioStock stock, Map<String, String> itemInfo) {
              Severity: Minor
              Found in src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java - About 35 mins to fix

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

                    private void persist() {
                        JSONObject json = new JSONObject();
                        for (String symbol : this.portfolioStocksInfo.keySet()) {
                            PortfolioStock item = this.portfolioStocksInfo.get(symbol);
                            if (item.hasData()) {
                Severity: Minor
                Found in src/main/java/nitezh/ministock/domain/PortfolioStockRepository.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

                There are no issues that match your filters.

                Category
                Status