Nick9500/ministocks

View on GitHub

Showing 105 of 108 total issues

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

    private static void doScheduledUpdates(Context context) {
        boolean doUpdates = true;
        Storage prefs = PreferenceStorage.getInstance(context);

        // Only update after start time

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

        @Override
        public void setWidgetPreferencesFromJson(JSONObject jsonPrefs) {
            String key;
            for (Iterator preferenceKey = jsonPrefs.keys(); preferenceKey.hasNext(); ) {
                key = (String) preferenceKey.next();
    Severity: Minor
    Found in src/main/java/nitezh/ministock/domain/AndroidWidget.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 getSuggestions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public Cursor getSuggestions(String query) {
            query = query == null ? "" : query.toLowerCase().trim();
            List<Map<String, String>> suggestions = StockSuggestions.getSuggestions(query);
    
            // Check whether an exact match is found in the symbol
    Severity: Minor
    Found in src/main/java/nitezh/ministock/SymbolProvider.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 onResume has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        protected void onResume() {
            super.onResume();
    
    
    
    Severity: Minor
    Found in src/main/java/nitezh/ministock/activities/PreferencesActivity.java - About 1 hr to fix

      Method choiceWithCallback has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static void choiceWithCallback(
                  Context context,
                  String title,
                  String negativeButtonText,
                  final CharSequence[] choices,
      Severity: Minor
      Found in src/main/java/nitezh/ministock/DialogTools.java - About 1 hr to fix

        Method getSuggestions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public Cursor getSuggestions(String query) {
                query = query == null ? "" : query.toLowerCase().trim();
                List<Map<String, String>> suggestions = StockSuggestions.getSuggestions(query);
        
                // Check whether an exact match is found in the symbol
        Severity: Minor
        Found in src/main/java/nitezh/ministock/SymbolProvider.java - About 1 hr to fix

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

              private String buildRequestUrl(List<String> symbols) {
                  StringBuilder sQuery = new StringBuilder();
                  for (String s : symbols) {
                      if (!s.equals("")) {
                          if (!sQuery.toString().equals("")) {
          src/main/java/nitezh/ministock/dataaccess/IexStockQuoteRepository.java on lines 48..59
          src/main/java/nitezh/ministock/dataaccess/YahooStockQuoteRepository2.java on lines 49..60

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

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

              private String buildRequestUrl(List<String> symbols) {
                  StringBuilder sQuery = new StringBuilder();
                  for (String s : symbols) {
                      if (!s.equals("")) {
                          if (!sQuery.toString().equals("")) {
          src/main/java/nitezh/ministock/dataaccess/GoogleStockQuoteRepository.java on lines 74..85
          src/main/java/nitezh/ministock/dataaccess/IexStockQuoteRepository.java on lines 48..59

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

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

              private String buildRequestUrl(List<String> symbols) {
                  StringBuilder sQuery = new StringBuilder();
                  for (String s : symbols) {
                      if (!s.equals("")) {
                          if (!sQuery.toString().equals("")) {
          src/main/java/nitezh/ministock/dataaccess/GoogleStockQuoteRepository.java on lines 74..85
          src/main/java/nitezh/ministock/dataaccess/YahooStockQuoteRepository2.java on lines 49..60

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

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

              @Override
              public Set<String> getWidgetsStockSymbols() {
                  Storage widgetPreferences;
                  Set<String> widgetStockSymbols = new HashSet<>();
                  for (int appWidgetId : this.getIds()) {
          Severity: Minor
          Found in src/main/java/nitezh/ministock/domain/AndroidWidgetRepository.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 getQuotes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public HashMap<String, StockQuote> getQuotes(Cache cache, List<String> symbols) {
                  HashMap<String, StockQuote> quotes = new HashMap<>();
                  HashMap<String, String> fxChanges = this.fxChangeRepository.getChanges(cache, symbols);
                  JSONArray jsonArray;
                  JSONObject quoteJson;

            Method getQuotes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public HashMap<String, StockQuote> getQuotes(Cache cache, List<String> symbols) {
                    HashMap<String, StockQuote> quotes = new HashMap<>();
                    HashMap<String, String> fxChanges = this.fxChangeRepository.getChanges(cache, symbols);
                    JSONArray jsonArray;
                    JSONObject quoteJson;

              Method getQuotes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public HashMap<String, StockQuote> getQuotes(Cache cache, List<String> symbols) {
                      HashMap<String, StockQuote> quotes = new HashMap<>();
                      HashMap<String, String> fxChanges = this.fxChangeRepository.getChanges(cache, symbols);
                      JSONArray jsonArray;
                      JSONObject quoteJson;

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

                    private void updatePrices() throws UiObjectNotFoundException {
                        String updatePricesNow = "Update prices now";
                        UiScrollable preferencesListView = new UiScrollable(new UiSelector());
                        preferencesListView.setMaxSearchSwipes(100);
                        preferencesListView.scrollTextIntoView(updatePricesNow);
                Severity: Major
                Found in src/androidTest/java/nitezh/ministock/SimpleUITesting.java and 4 other locations - About 1 hr to fix
                src/androidTest/java/nitezh/ministock/ExportUITests.java on lines 51..61
                src/androidTest/java/nitezh/ministock/ExportUITests.java on lines 72..82
                src/androidTest/java/nitezh/ministock/ImportUITests.java on lines 46..56
                src/androidTest/java/nitezh/ministock/SimpleUITesting.java on lines 135..145

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

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

                    private void selectStockSetup() throws UiObjectNotFoundException {
                        String stockSetup = "Stocks setup";
                        UiScrollable preferencesListView = new UiScrollable(new UiSelector());
                        preferencesListView.setMaxSearchSwipes(100);
                        preferencesListView.scrollTextIntoView(stockSetup);
                Severity: Major
                Found in src/androidTest/java/nitezh/ministock/ExportUITests.java and 4 other locations - About 1 hr to fix
                src/androidTest/java/nitezh/ministock/ExportUITests.java on lines 72..82
                src/androidTest/java/nitezh/ministock/ImportUITests.java on lines 46..56
                src/androidTest/java/nitezh/ministock/SimpleUITesting.java on lines 135..145
                src/androidTest/java/nitezh/ministock/SimpleUITesting.java on lines 187..197

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

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

                    private void clickExport() throws UiObjectNotFoundException  {
                        String export = "Export";
                        UiScrollable preferencesListView = new UiScrollable(new UiSelector());
                        preferencesListView.setMaxSearchSwipes(100);
                        preferencesListView.scrollTextIntoView(export);
                Severity: Major
                Found in src/androidTest/java/nitezh/ministock/ExportUITests.java and 4 other locations - About 1 hr to fix
                src/androidTest/java/nitezh/ministock/ExportUITests.java on lines 51..61
                src/androidTest/java/nitezh/ministock/ImportUITests.java on lines 46..56
                src/androidTest/java/nitezh/ministock/SimpleUITesting.java on lines 135..145
                src/androidTest/java/nitezh/ministock/SimpleUITesting.java on lines 187..197

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

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

                    private void clickImport() throws UiObjectNotFoundException  {
                        String importBtn = "Import";
                        UiScrollable preferencesListView = new UiScrollable(new UiSelector());
                        preferencesListView.setMaxSearchSwipes(100);
                        preferencesListView.scrollTextIntoView(importBtn);
                Severity: Major
                Found in src/androidTest/java/nitezh/ministock/ImportUITests.java and 4 other locations - About 1 hr to fix
                src/androidTest/java/nitezh/ministock/ExportUITests.java on lines 51..61
                src/androidTest/java/nitezh/ministock/ExportUITests.java on lines 72..82
                src/androidTest/java/nitezh/ministock/SimpleUITesting.java on lines 135..145
                src/androidTest/java/nitezh/ministock/SimpleUITesting.java on lines 187..197

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

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

                    private void selectStockSetup() throws UiObjectNotFoundException {
                        String stockSetup = "Stocks setup";
                        UiScrollable preferencesListView = new UiScrollable(new UiSelector());
                        preferencesListView.setMaxSearchSwipes(100);
                        preferencesListView.scrollTextIntoView(stockSetup);
                Severity: Major
                Found in src/androidTest/java/nitezh/ministock/SimpleUITesting.java and 4 other locations - About 1 hr to fix
                src/androidTest/java/nitezh/ministock/ExportUITests.java on lines 51..61
                src/androidTest/java/nitezh/ministock/ExportUITests.java on lines 72..82
                src/androidTest/java/nitezh/ministock/ImportUITests.java on lines 46..56
                src/androidTest/java/nitezh/ministock/SimpleUITesting.java on lines 187..197

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

                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

                Severity
                Category
                Status
                Source
                Language