Nick9500/ministocks

View on GitHub

Showing 105 of 108 total issues

File PreferencesActivity.java has 764 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/PreferencesActivity.java - About 1 day to fix

    PreferencesActivity has 70 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class PreferencesActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
    
        // Constants
        private static final int STRING_TYPE = 0;
        private static final int LIST_TYPE = 1;
    Severity: Major
    Found in src/main/java/nitezh/ministock/activities/PreferencesActivity.java - About 1 day to fix

      Method onCreate has 245 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              addPreferencesFromResource(R.xml.preferences);
      
      
      Severity: Major
      Found in src/main/java/nitezh/ministock/activities/PreferencesActivity.java - About 1 day to fix

        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

          AndroidWidget has 38 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class AndroidWidget implements Widget {
          
              private final Storage storage;
              private final Context context;
              private final int id;
          Severity: Minor
          Found in src/main/java/nitezh/ministock/domain/AndroidWidget.java - About 5 hrs to fix

            Widget has 37 methods (exceeds 20 allowed). Consider refactoring.
            Open

            public interface Widget {
                Storage getStorage();
            
                void setWidgetPreferencesFromJson(JSONObject jsonPrefs);
            
            
            Severity: Minor
            Found in src/main/java/nitezh/ministock/domain/Widget.java - About 4 hrs to fix

              Method doInBackground has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
              Open

                  @Override
                  protected List<String> doInBackground(String... strings) {
                      List<String> closingValuesWeekly = new ArrayList<>();
              
                      try {
              Severity: Minor
              Found in src/main/java/nitezh/ministock/activities/GlobalWidgetData.java - About 4 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 showPortfolioItemEdit has 97 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private void showPortfolioItemEdit(AdapterView<?> a, int position) {
                      // Create the portfolio item edit dialog
                      final Dialog portfolioItemEdit = new Dialog(this);
                      portfolioItemEdit.setContentView(R.layout.portfolio_item);
              
              
              Severity: Major
              Found in src/main/java/nitezh/ministock/activities/PortfolioActivity.java - About 3 hrs 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 doInBackground has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      @Override
                      protected List<String> doInBackground(String... strings) {
                          List<String> closingValuesWeekly = new ArrayList<>();
                  
                          try {
                  Severity: Major
                  Found in src/main/java/nitezh/ministock/activities/GlobalWidgetData.java - About 3 hrs to fix

                    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

                      Identical blocks of code found in 3 locations. 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;
                      src/main/java/nitezh/ministock/dataaccess/YahooStockQuoteRepository.java on lines 51..80
                      src/main/java/nitezh/ministock/dataaccess/YahooStockQuoteRepository2.java on lines 62..91

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

                      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 3 locations. 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;
                      src/main/java/nitezh/ministock/dataaccess/IexStockQuoteRepository.java on lines 61..90
                      src/main/java/nitezh/ministock/dataaccess/YahooStockQuoteRepository2.java on lines 62..91

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

                      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 3 locations. 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;
                      src/main/java/nitezh/ministock/dataaccess/IexStockQuoteRepository.java on lines 61..90
                      src/main/java/nitezh/ministock/dataaccess/YahooStockQuoteRepository.java on lines 51..80

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

                      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

                      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 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 onResume has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              @Override
                              public void onResume() {
                                  super.onResume();
                                  int interval = GlobalWidgetData.getInterval();
                                  int position = getIntent().getIntExtra(WidgetProviderBase.ROW_POSITION, 0);
                          Severity: Major
                          Found in src/main/java/nitezh/ministock/activities/ChartActivity.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 updateSummaries has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private void updateSummaries(SharedPreferences sharedPreferences, String key) {
                                      Preference preference = findPreference(key);
                              
                                      if (preference != null) {
                              
                              
                              Severity: Minor
                              Found in src/main/java/nitezh/ministock/activities/PreferencesActivity.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 sendEmailToUser has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private void sendEmailToUser() {
                              
                                      // Set up the input
                                      final EditText input = new EditText(this);
                                      input.setId(R.id.emailFieldID);
                              Severity: Major
                              Found in src/main/java/nitezh/ministock/activities/PreferencesActivity.java - About 2 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language