davidmigloz/go-bees

View on GitHub
app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesLocalDataSource.java

Summary

Maintainability
D
2 days
Test Coverage

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

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

          @SuppressWarnings("ConstantConditions")
          @Override
          public void updateApiariesCurrentWeather(final List<Apiary> apiariesToUpdate,
                                                   @NonNull TaskCallback callback) {
              try {

        Method getHiveWithRecordings has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public void getHiveWithRecordings(long hiveId, @NonNull GetHiveCallback callback) {
                try {
                    // Get hive
                    Hive hive = realm.where(Hive.class).equalTo(ID, hiveId).findFirst();

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

              @Override
              public void getRecording(long apiaryId, long hiveId, Date start, Date end,
                                       @NonNull GetRecordingCallback callback) {
                  // Get apiary
                  Apiary apiary = realm.where(Apiary.class).equalTo(ID, apiaryId).findFirst();

            Method deleteRecording has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Override
                public void deleteRecording(long hiveId, @NonNull Recording recording,
                                            @NonNull TaskCallback callback) {
                    try {
                        // Get hive

              Method deleteApiary has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @Override
                  public void deleteApiary(long apiaryId, @NonNull TaskCallback callback) {
                      try {
                          // Get apiary
                          final Apiary apiary = realm.where(Apiary.class).equalTo(ID, apiaryId).findFirst();

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

                    @Override
                    public void saveRecords(final long hiveId, @NonNull final List<Record> records,
                                            @NonNull SaveRecordingCallback callback) {
                        if (records.size() < 5) {
                            // Recording too short

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

                      public void getRecording(long apiaryId, long hiveId, Date start, Date end,
                                               @NonNull GetRecordingCallback callback) {

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

                        @Override
                        public void getHiveWithRecordings(long hiveId, @NonNull GetHiveCallback callback) {
                            try {
                                // Get hive
                                Hive hive = realm.where(Hive.class).equalTo(ID, hiveId).findFirst();

                    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

                        @Override
                        public void getHive(long hiveId, @NonNull GetHiveCallback callback) {
                            try {
                                Hive hive = realm.where(Hive.class).equalTo(ID, hiveId).findFirst();
                                callback.onHiveLoaded(realm.copyFromRealm(hive));
                    app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesLocalDataSource.java on lines 107..116

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

                    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

                        @Override
                        public void getApiary(long apiaryId, @NonNull GetApiaryCallback callback) {
                            try {
                                Apiary apiary = realm.where(Apiary.class).equalTo(ID, apiaryId).findFirst();
                                callback.onApiaryLoaded(realm.copyFromRealm(apiary));
                    app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesLocalDataSource.java on lines 229..238

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

                    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

                        @Override
                        public void getNextHiveId(@NonNull GetNextHiveIdCallback callback) {
                            Number nextId = realm.where(Hive.class).max(ID);
                            callback.onNextHiveIdLoaded(nextId != null ? nextId.longValue() + 1 : 0);
                        }
                    app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesLocalDataSource.java on lines 202..206

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

                    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

                        @Override
                        public void getNextApiaryId(@NonNull GetNextApiaryIdCallback callback) {
                            Number nextId = realm.where(Apiary.class).max(ID);
                            callback.onNextApiaryIdLoaded(nextId != null ? nextId.longValue() + 1 : 0);
                        }
                    app/src/main/java/com/davidmiguel/gobees/data/source/local/GoBeesLocalDataSource.java on lines 340..344

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

                    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

                    Local variable name 'h' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
                    Open

                                            Hive h = apiary.getHives().where().equalTo(ID, hive.getId()).findFirst();

                    Checks that local, non-final variable names conform to a specified pattern.A catch parameter is considered to be a local variable.

                    This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

                    Line is longer than 100 characters (found 101).
                    Open

                        public void getAndSaveMeteoRecord(@NonNull final Apiary apiary, @NonNull TaskCallback callback) {

                    Checks for long lines.

                    Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

                    This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

                    Local variable name 'n' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
                    Open

                                Number n = realm.where(Record.class).max(ID);

                    Checks that local, non-final variable names conform to a specified pattern.A catch parameter is considered to be a local variable.

                    This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

                    Local variable name 'n' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
                    Open

                                        Number n = realm.where(MeteoRecord.class).max(ID);

                    Checks that local, non-final variable names conform to a specified pattern.A catch parameter is considered to be a local variable.

                    This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

                    Local variable name 'n' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
                    Open

                                        Number n = realm.where(MeteoRecord.class).max(ID);

                    Checks that local, non-final variable names conform to a specified pattern.A catch parameter is considered to be a local variable.

                    This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

                    Line is longer than 100 characters (found 102).
                    Open

                        public void saveMeteoRecords(final long apiaryId, @NonNull final List<MeteoRecord> meteoRecords) {

                    Checks for long lines.

                    Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

                    This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

                    Local variable name 'n' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
                    Open

                                    Number n = realm.where(MeteoRecord.class).max(ID);

                    Checks that local, non-final variable names conform to a specified pattern.A catch parameter is considered to be a local variable.

                    This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

                    There are no issues that match your filters.

                    Category
                    Status