Nick9500/ministocks

View on GitHub

Showing 105 of 108 total issues

Method loadQuotes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private HashMap<String, StockQuote> loadQuotes() {
        if (mCachedQuotes != null && !mCachedQuotes.isEmpty()) {
            return mCachedQuotes;
        }

Severity: Minor
Found in src/main/java/nitezh/ministock/domain/StockQuoteRepository.java - About 55 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 onResume has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    protected void onResume() {
        super.onResume();


Severity: Minor
Found in src/main/java/nitezh/ministock/activities/PreferencesActivity.java - About 55 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 onSharedPreferenceChanged has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        // Perform some custom handling of some values

        if (key.startsWith("Stock") && !key.endsWith("_summary")) {
Severity: Minor
Found in src/main/java/nitezh/ministock/activities/PreferencesActivity.java - About 55 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

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

    private void setStock(int index, List<Integer> keyCodes) throws UiObjectNotFoundException {
        UiObject searchField = selectStockView(index);
        searchField.clearTextField();
        for (Integer keyCode : keyCodes)
            mDevice.pressKeyCode(keyCode);
Severity: Minor
Found in src/androidTest/java/nitezh/ministock/ExportUITests.java and 1 other location - About 55 mins to fix
src/androidTest/java/nitezh/ministock/SimpleUITesting.java on lines 164..173

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

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

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

    private void setStock(int index, List<Integer> keyCodes) throws UiObjectNotFoundException {
        UiObject searchField = selectStockView(index);
        searchField.clearTextField();
        for (Integer keyCode : keyCodes)
            mDevice.pressKeyCode(keyCode);
Severity: Minor
Found in src/androidTest/java/nitezh/ministock/SimpleUITesting.java and 1 other location - About 55 mins to fix
src/androidTest/java/nitezh/ministock/ExportUITests.java on lines 104..113

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

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 inputWithCallback has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static void inputWithCallback(Context context, String title, String body,
                                         String positiveButtonText, String negativeButtonText,
                                         String defaultInputText,
                                         final InputAlertCallable callable) {
Severity: Major
Found in src/main/java/nitezh/ministock/DialogTools.java - About 50 mins to fix

    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 alertWithCallback has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                  Context context,
                  String title,
                  String body,
                  String positiveButtonText,
                  String negativeButtonText,
      Severity: Major
      Found in src/main/java/nitezh/ministock/DialogTools.java - About 50 mins to fix

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

                if (!widget.isNarrow()) {
                    if (stockInfoExtra != null) {
                        String infoExtraText = stockInfoExtra;
                        if (stockInfoExtraIsCurrency) {
                            infoExtraText = CurrencyTools.addCurrencyToSymbol(stockInfoExtra, symbol);
        src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 349..359

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

        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

            private void SetStockInfoTextAndColour(String symbol, WidgetRow widgetRow, String stockInfo, Boolean stockInfoIsCurrency) {
                if (stockInfo != null) {
                    String infoText = stockInfo;
                    if (stockInfoIsCurrency) {
                        infoText = CurrencyTools.addCurrencyToSymbol(stockInfo, symbol);
        src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 335..346

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

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

              public static String getTrimmedDouble(double number, int digits, Integer maxPrecision) {
                  String numberAsString = Double.toString(number);
          
                  // Find the position of the decimal point
                  int decimalPos = numberAsString.indexOf(".");
          Severity: Minor
          Found in src/main/java/nitezh/ministock/utils/NumberTools.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

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

                          case "REFRESH":
                              Bundle refExtras = intent.getExtras();
                              if (refExtras != null) {
                                  int refAppWidgetId = refExtras.getInt(
                                          AppWidgetManager.EXTRA_APPWIDGET_ID,
          src/main/java/nitezh/ministock/activities/widget/WidgetProviderBase.java on lines 165..173

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

          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

                          case "PREFERENCES":
                              Bundle extras = intent.getExtras();
                              if (extras != null) {
                                  int appWidgetId = extras.getInt(
                                          AppWidgetManager.EXTRA_APPWIDGET_ID,
          src/main/java/nitezh/ministock/activities/widget/WidgetProviderBase.java on lines 174..182

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

          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

                      case VIEW_PL_CHANGE:
                          plView = true;
                          priceColumn = widgetStock.getPlHolding();
                          stockInfoExtra = widgetStock.getTotalPercent();
                          stockInfo = widgetStock.getPlTotalChange();
          src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 293..299

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

          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

                      case VIEW_PL_DAILY_CHANGE:
                          plView = true;
                          priceColumn = widgetStock.getPlHolding();
                          stockInfoExtra = widgetStock.getDailyPercent();
                          stockInfo = widgetStock.getPlDailyChange();
          src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 307..313

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

          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 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 applyUpdate has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public static void applyUpdate(Context context, int appWidgetId, UpdateType updateMode,
                                               HashMap<String, StockQuote> quotes, String quotesTimeStamp) {
            Severity: Minor
            Found in src/main/java/nitezh/ministock/activities/widget/WidgetProviderBase.java - About 35 mins to fix

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

                  public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
              Severity: Minor
              Found in src/main/java/nitezh/ministock/SymbolProvider.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
                  Severity
                  Category
                  Status
                  Source
                  Language