davidmigloz/go-bees

View on GitHub

Showing 387 of 387 total issues

Method getStringForWeatherCondition has 219 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static String getStringForWeatherCondition(Context context, int weatherId) {
        int stringId;
        switch (weatherId) {
            case 200:
                stringId = R.string.condition_200;
Severity: Major
Found in app/src/main/java/com/davidmiguel/gobees/utils/WeatherUtils.java - About 1 day to fix

    File GoBeesLocalDataSource.java has 454 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * GoBees
     * Copyright (c) 2016 - 2017 David Miguel Lozano
     *
     * This program is free software: you can redistribute it and/or modify

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

          private static final int[] SWARMING_NUM_BEES = {
                  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7h
                  1, 2, 1, 1, 1, 2, 2, 3, 1, 1, 2, 1, // 8h
                  2, 3, 2, 4, 6, 7, 5, 4, 6, 5, 4, 7, // 9h
                  10, 9, 11, 12, 30, 38, 39, 39, 10, 9, 11, 10, // 10h
      app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java on lines 52..67
      app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java on lines 78..93

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

      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 static final int[] GOOD_NUM_BEES = {
                  0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 0, 1, 0, // 7h
                  1, 1, 2, 1, 2, 2, 2, 3, 3, 4, 2, 4, // 8h
                  4, 5, 7, 6, 6, 7, 5, 4, 6, 5, 4, 7, // 9h
                  10, 9, 11, 12, 11, 11, 10, 12, 11, 10, 11, 11, // 10h
      app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java on lines 78..93
      app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java on lines 104..119

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

      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 static final int[] VERY_LOW_NUM_BEES = {
                  0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, // 7h
                  0, 0, 1, 1, 0, 0, 1, 1, 2, 1, 0, 0, // 8h
                  0, 1, 1, 1, 1, 2, 2, 1, 0, 0, 0, 0, // 9h
                  1, 1, 1, 2, 2, 1, 3, 1, 1, 0, 1, 1, // 10h
      app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java on lines 52..67
      app/src/main/java/com/davidmiguel/gobees/data/source/local/DataGenerator.java on lines 104..119

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

      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

      GoBeesLocalDataSource has 41 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public class GoBeesLocalDataSource implements GoBeesDataSource {
      
          // Fields names
          private static final String ID = "id";
          private static final String TIMESTAMP = "timestamp";

        Method parseCurrentWeatherJson has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

            static MeteoRecord parseCurrentWeatherJson(String weatherJson) throws JSONException {
                // Get JSON
                JSONObject jsonObject = new JSONObject(weatherJson);
        
                // Check errors

        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

        GoBeesRepository has 36 methods (exceeds 20 allowed). Consider refactoring.
        Open

        @SuppressWarnings("WeakerAccess")
        public class GoBeesRepository implements GoBeesDataSource {
        
            private static GoBeesRepository instance = null;
        

          HiveRecordingsFragment has 33 methods (exceeds 20 allowed). Consider refactoring.
          Open

          public class HiveRecordingsFragment extends Fragment
                  implements BaseTabFragment, HiveContract.HiveRecordingsView, RecordingsAdapter.RecordingItemListener {
          
              public static final String ARGUMENT_APIARY_ID = "APIARY_ID";
              public static final String ARGUMENT_HIVE_ID = "HIVE_ID";

            File RecordingFragment.java has 339 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*
             * GoBees
             * Copyright (c) 2016 - 2017 David Miguel Lozano
             *
             * This program is free software: you can redistribute it and/or modify

              File WeatherUtils.java has 327 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /*
               * GoBees
               * Copyright (c) 2016 - 2017 David Miguel Lozano
               *
               * This program is free software: you can redistribute it and/or modify
              Severity: Minor
              Found in app/src/main/java/com/davidmiguel/gobees/utils/WeatherUtils.java - About 3 hrs to fix

                MeteoRecord has 30 methods (exceeds 20 allowed). Consider refactoring.
                Open

                @SuppressWarnings("unused")
                public class MeteoRecord extends RealmObject {
                
                    @PrimaryKey
                    private long id;
                Severity: Minor
                Found in app/src/main/java/com/davidmiguel/gobees/data/model/MeteoRecord.java - About 3 hrs to fix

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

                  public class GoBeesRepositoryTest {
                  
                      private static final long APIARY_ID = 1;
                  
                      private static final long HIVE_ID = 1;

                    MonitoringFragment has 28 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    public class MonitoringFragment extends Fragment implements MonitoringContract.View,
                            BackClickHelperFragment {
                    
                        public static final String ARGUMENT_APIARY_ID = "APIARY_ID";
                        public static final String ARGUMENT_HIVE_ID = "HIVE_ID";

                      GoBeesDataSource has 27 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      public interface GoBeesDataSource {
                      
                          /**
                           * Opens database.
                           */

                        AddEditApiaryFragment has 27 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        public class AddEditApiaryFragment extends Fragment implements AddEditApiaryContract.View {
                        
                            public static final String ARGUMENT_EDIT_APIARY_ID = "EDIT_APIARY_ID";
                        
                            private AddEditApiaryContract.Presenter presenter;

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

                              private void setupWindChart(List<MeteoRecord> meteo) {
                                  // Setup data
                                  List<Entry> entries = new ArrayList<>();
                                  // Add as first entry a copy of the first wind record
                                  // First relative timestamp is 0
                          app/src/main/java/com/davidmiguel/gobees/recording/RecordingFragment.java on lines 365..392

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

                          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 setupRainChart(List<MeteoRecord> meteo) {
                                  // Setup data
                                  List<Entry> entries = new ArrayList<>();
                                  // Add as first entry a copy of the first rain record
                                  // First relative timestamp is 0
                          app/src/main/java/com/davidmiguel/gobees/recording/RecordingFragment.java on lines 400..427

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

                          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

                          ApiaryHivesFragment has 26 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          public class ApiaryHivesFragment extends Fragment
                                  implements BaseTabFragment, ApiaryContract.ApiaryHivesView, HivesAdapter.HiveItemListener {
                          
                              public static final String ARGUMENT_APIARY_ID = "APIARY_ID";
                          

                            Method parseCurrentWeatherJson has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                static MeteoRecord parseCurrentWeatherJson(String weatherJson) throws JSONException {
                                    // Get JSON
                                    JSONObject jsonObject = new JSONObject(weatherJson);
                            
                                    // Check errors
                              Severity
                              Category
                              Status
                              Source
                              Language