nheyek/SDP-2018

View on GitHub
app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.java

Summary

Maintainability
C
1 day
Test Coverage

File Firestore.java has 282 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package ch.epfl.sweng.studyup.firebase;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
Severity: Minor
Found in app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.java - About 2 hrs to fix

    Firestore has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class Firestore {
    
        private static FirebaseFirestore db = FirebaseFirestore.getInstance();
        private static final String TAG = Firestore.class.getSimpleName();
        private static Firestore instance = null;
    Severity: Minor
    Found in app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.java - About 2 hrs to fix

      Method addPlayerToTeachingStaff has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public void addPlayerToTeachingStaff(final Course c, final String sciper) {
              final DocumentReference courseRef = db.collection(FB_COURSES).document(c.name());
              courseRef.get()
                      .addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
                          @Override
      Severity: Minor
      Found in app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.java - About 1 hr to fix

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

            public void updateRemotePlayerDataFromLocal() {
        
                Player currPlayer = Player.get();
                Map<String, Object> localPlayerData = new HashMap<>();
        
        
        Severity: Minor
        Found in app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.java - About 1 hr to fix

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

              private Question extractQuestionData(Player currPlayer, String id, Map<String, Object> questionData) {
                  if(!MOCK_ENABLED && MOCK_UUIDS.contains(id)) return null;
                  Course questionCourse = Course.valueOf(questionData.get(FB_COURSE).toString());
                  List<Course> playerCourse = currPlayer.isTeacher() ? currPlayer.getCoursesTeached() : currPlayer.getCoursesEnrolled();
                  boolean questionCourseMatchesPlayer = playerCourse.contains(questionCourse);
          Severity: Minor
          Found in app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.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

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

                                      try {
                                          teachers = (List<String>) doc.getData().get(FB_TEACHING_STAFF);
                                      } catch(ClassCastException e) { Log.d(TAG, "onComplete: The info for the teacher of "+c.name()+" is incorrect."); return; }
          Severity: Minor
          Found in app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.java and 1 other location - About 35 mins to fix
          app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.java on lines 264..269

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

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

                                          try {
                                              teachers = (List<String>) doc.getData().get(FB_TEACHING_STAFF);
                                          } catch (ClassCastException e) {
                                              Log.d(TAG, "onComplete: The info for the teacher of " + c.name() + " is incorrect.");
                                              return;
          Severity: Minor
          Found in app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.java and 1 other location - About 35 mins to fix
          app/src/main/java/ch/epfl/sweng/studyup/firebase/Firestore.java on lines 301..303

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

          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