Nick9500/ministocks

View on GitHub
src/main/java/nitezh/ministock/activities/widget/WidgetView.java

Summary

Maintainability
F
4 days
Test Coverage

File WidgetView.java has 518 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 The MIT License
 
 Copyright (c) 2013 Nitesh Patel http://niteshpatel.github.io/ministocks
 
Severity: Major
Found in src/main/java/nitezh/ministock/activities/widget/WidgetView.java - About 1 day to fix

    WidgetView has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class WidgetView {
    
        private final RemoteViews remoteViews;
        private final Widget widget;
        private final boolean hasPortfolioData;
    Severity: Minor
    Found in src/main/java/nitezh/ministock/activities/widget/WidgetView.java - About 3 hrs to fix

      Method getRowInfo has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public WidgetRow getRowInfo(String symbol, ViewType widgetView) {
              WidgetRow widgetRow = new WidgetRow(this.widget);
              StockQuote quote = this.quotes.get(symbol);
      
              widgetRow.setSymbol(symbol);
      Severity: Major
      Found in src/main/java/nitezh/ministock/activities/widget/WidgetView.java - About 2 hrs to fix

        Method getLabel has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private String getLabel(int widgetDisplay) {
                // Set the widget view text in the footer
                String label = "";
                if (widget.isNarrow()) {
                    switch (ViewType.values()[widgetDisplay]) {
        Severity: Major
        Found in src/main/java/nitezh/ministock/activities/widget/WidgetView.java - About 2 hrs to fix

          Method getBlankRemoteViews has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              private RemoteViews getBlankRemoteViews(Widget widget, String packageName) {
                  String backgroundStyle = widget.getBackgroundStyle();
                  boolean useLargeFont = widget.useLargeFont();
          
                  RemoteViews views;
          Severity: Minor
          Found in src/main/java/nitezh/ministock/activities/widget/WidgetView.java - About 2 hrs 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 getBlankRemoteViews has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private RemoteViews getBlankRemoteViews(Widget widget, String packageName) {
                  String backgroundStyle = widget.getBackgroundStyle();
                  boolean useLargeFont = widget.useLargeFont();
          
                  RemoteViews views;
          Severity: Minor
          Found in src/main/java/nitezh/ministock/activities/widget/WidgetView.java - About 1 hr to fix

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

                private int getImageViewSrcId(String backgroundStyle, Boolean useLargeFont) {
                    Integer imageViewSrcId;
                    switch (backgroundStyle) {
                        case "transparent":
                            if (useLargeFont) {
            Severity: Minor
            Found in src/main/java/nitezh/ministock/activities/widget/WidgetView.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

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

                private String getLabel(int widgetDisplay) {
                    // Set the widget view text in the footer
                    String label = "";
                    if (widget.isNarrow()) {
                        switch (ViewType.values()[widgetDisplay]) {
            Severity: Minor
            Found in src/main/java/nitezh/ministock/activities/widget/WidgetView.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 SetStockInfoExtraTextAndColourForWideWidget has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private void SetStockInfoExtraTextAndColourForWideWidget(String symbol, WidgetRow widgetRow, String stockInfoExtra, Boolean stockInfoExtraIsCurrency) {
                    if (!widget.isNarrow()) {
                        if (stockInfoExtra != null) {
                            String infoExtraText = stockInfoExtra;
                            if (stockInfoExtraIsCurrency) {
            Severity: Minor
            Found in src/main/java/nitezh/ministock/activities/widget/WidgetView.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

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

                    if (widget.isNarrow()) {
                        switch (ViewType.values()[widgetDisplay]) {
                            case VIEW_DAILY_PERCENT:
                                label = "";
                                break;
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 579..621

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

            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

                    } else {
                        switch (ViewType.values()[widgetDisplay]) {
                            case VIEW_DAILY_PERCENT:
                                label = "";
                                break;
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 537..579

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

            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

                    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

            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

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

                    } else {
                        if (useLargeFont) {
                            views = new RemoteViews(packageName, R.layout.widget_1x2_large);
                        } else {
                            views = new RemoteViews(packageName, R.layout.widget_1x2);
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 121..127
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 115..121
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 109..115

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

            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 4 locations. Consider refactoring.
            Open

                    } else if (widget.getSize() == 2) {
                        if (useLargeFont) {
                            views = new RemoteViews(packageName, R.layout.widget_2x2_large);
                        } else {
                            views = new RemoteViews(packageName, R.layout.widget_2x2);
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 127..133
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 121..127
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 109..115

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

            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 4 locations. Consider refactoring.
            Open

                    if (widget.getSize() == 1) {
                        if (useLargeFont) {
                            views = new RemoteViews(packageName, R.layout.widget_1x4_large);
                        } else {
                            views = new RemoteViews(packageName, R.layout.widget_1x4);
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 127..133
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 121..127
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 115..121

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

            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 4 locations. Consider refactoring.
            Open

                    } else if (widget.getSize() == 3) {
                        if (useLargeFont) {
                            views = new RemoteViews(packageName, R.layout.widget_2x4_large);
                        } else {
                            views = new RemoteViews(packageName, R.layout.widget_2x4);
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 127..133
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 115..121
            src/main/java/nitezh/ministock/activities/widget/WidgetView.java on lines 109..115

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

            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

            There are no issues that match your filters.

            Category
            Status