src/main/java/nitezh/ministock/domain/PortfolioStockRepository.java
File PortfolioStockRepository.java
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*
The MIT License
Copyright (c) 2013 Nitesh Patel http://niteshpatel.github.io/ministocks
PortfolioStockRepository
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
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;
Method getStocks
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
HashMap<String, PortfolioStock> getStocks() {
if (!isDirtyPortfolioStockMap()) {
return mPortfolioStocks;
}
mPortfolioStocks.clear();
Method getStocks
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
HashMap<String, PortfolioStock> getStocks() {
if (!isDirtyPortfolioStockMap()) {
return mPortfolioStocks;
}
mPortfolioStocks.clear();
- Read upRead up
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
Open
public void updateStock(String symbol, String price, String date, String quantity,
String limitHigh, String limitLow, String customDisplay) {
Method populateDisplayTotalChange
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private void populateDisplayTotalChange(NumberFormat numberFormat, String symbol, PortfolioStock stock, Map<String, String> itemInfo, String currentPrice, String buyPrice) {
Method populateDisplayHoldingValue
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private void populateDisplayHoldingValue(NumberFormat numberFormat, String symbol, PortfolioStock stock, Map<String, String> itemInfo, String currentPrice) {
Method populateDisplayLastChange
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private void populateDisplayLastChange(NumberFormat numberFormat, String symbol, StockQuote quote, PortfolioStock stock, Map<String, String> itemInfo) {
Method persist
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
private void persist() {
JSONObject json = new JSONObject();
for (String symbol : this.portfolioStocksInfo.keySet()) {
PortfolioStock item = this.portfolioStocksInfo.get(symbol);
if (item.hasData()) {
- Read upRead up
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"