nheyek/SDP-2018

View on GitHub

Showing 58 of 124 total issues

Consider simplifying this complex logical expression.
Open

        if (!Player.get().getKnownNPCs().contains(name)
                && GlobalAccessVariables.NPCInteractionState
                && !(currentActivity instanceof MapsActivity)
                && Rooms.distanceBetweenTwoLatLng(npcLatLng, playerLatLng) < Constants.NPC_RANGE
                && (counter >= MAX_COUNTER || isFirstInteraction)) {
Severity: Major
Found in app/src/main/java/ch/epfl/sweng/studyup/npc/NPC.java - About 40 mins to fix

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

        private static void setupRadioButtonForMCQ(Activity act, RadioButton r1, RadioButton r2, RadioButton r3, RadioButton r4) {

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

          private void testManageCourseSample(int listViewToClickOn, int buttonToClick, int otherCoursesChangeCount, int pendingCoursesChangeCount, int acceptedCoursesChangeCount) {

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

            private void setButtonsBackground(LinearLayout leaderboardByQuestionsAnsweredContainer, LinearLayout leaderboardByXPContainer, Button rankModeXpButton, Button rankModeCorrectAnswersButton, boolean byXP) {
        Severity: Minor
        Found in app/src/main/java/ch/epfl/sweng/studyup/player/LeaderboardActivity.java - About 35 mins to fix

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

              private static void setupRadioButtonForTrueFalse(Activity act, RadioButton r1, RadioButton r2, RadioButton r3, RadioButton r4) {

            Method onSuccess has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                        @Override
                        public void onSuccess(Location location) {
                            if (location != null) {
                                // Log.d("GPS_MAP", "NEW POS: Latitude = " + location.getLatitude() + "  Longitude: " + location.getLongitude());
                                POSITION = new LatLng(location.getLatitude(), location.getLongitude());
            Severity: Minor
            Found in app/src/main/java/ch/epfl/sweng/studyup/map/BackgroundLocation.java - About 35 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

            Method attemptLoginFromCache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private boolean attemptLoginFromCache() throws Exception {
            
                    FileCacher<List<String>> loginPersistenceCache = new FileCacher<>(this, PERSIST_LOGIN_FILENAME);
            
                    try {
            Severity: Minor
            Found in app/src/main/java/ch/epfl/sweng/studyup/LoginActivity.java - About 35 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

            Method handleTimedQuestion has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private void handleTimedQuestion(Question displayQuestion) {
                    String questionId = displayQuestion.getQuestionId();
                    TextView time_left = findViewById(R.id.time_left); ImageView alarm = findViewById(R.id.alarmImage);
                    long now = System.currentTimeMillis(); String displayedText;
                    long duration = displayQuestion.getDuration();

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

                public void answerQuestion(View view) {
                    int chkTOP = answerGroupTOP.getCheckedRadioButtonId();
                    int chkBOT = answerGroupBOT.getCheckedRadioButtonId();
                    if(Player.get().getAnsweredQuestion().containsKey(displayQuestion.getQuestionId())) {
                        Toast.makeText(this, getString(R.string.text_cantanswertwice), Toast.LENGTH_SHORT).show();

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

                private Map<String, Integer> getNbrAnswerPerCourse(List<Question> questions) {
                    Map<String, List<String>> answersInfoById = Player.get().getAnsweredQuestion();
                    Map<String, Integer> nbrAnswerPerCourse = new HashMap<>();
                    for(Question q : questions) {
                        String course = q.getCourseName();
            Severity: Minor
            Found in app/src/main/java/ch/epfl/sweng/studyup/player/HomeActivity.java - About 35 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

            Avoid too many return statements within this method.
            Open

                            return;
            Severity: Major
            Found in app/src/main/java/ch/epfl/sweng/studyup/utils/Utils.java - About 30 mins to fix

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

                  public void onLoginButtonClick(View view) {
              
                      RadioGroup roles = findViewById(R.id.StudentOrTeacherButtons);
                      RadioButton checkedRole = findViewById(roles.getCheckedRadioButtonId());
                      if (checkedRole == null) {
              Severity: Minor
              Found in app/src/main/java/ch/epfl/sweng/studyup/LoginActivity.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

              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

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

                  public static boolean checkIfUserIsInRoom() {
                      if(Player.get().getCoursesEnrolled().isEmpty() || Player.get().getScheduleStudent().isEmpty() ||
                              POSITION == null) {
                          return false;
                      }
              Severity: Minor
              Found in app/src/main/java/ch/epfl/sweng/studyup/utils/Rooms.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

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

                  @Override
                  protected void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      setContentView(R.layout.activity_login);
              
              
              Severity: Minor
              Found in app/src/main/java/ch/epfl/sweng/studyup/LoginActivity.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

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

                      private void setupTime(TextView timeTextview, double progress, long questionDuration) {
                          long millisRemaining = (long) (progress * questionDuration);
                          long hourRemaining = millisRemaining / (3600 * 1000);
                          long minRemaining = (millisRemaining - hourRemaining * 3600 * 1000) / (1000 * 60);
                          String timeRemaining;

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

                  public void setupLocksAndClickable() {
                      Set<String> unlockedThemes = Player.get().getUnlockedThemes();
              
                      for (String theme : unlockedThemes) {
                          if(theme.equals(SETTINGS_COLOR_GREEN))  {

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

                  public void setCourses(List<Course> courses) {
                      if(isStudent()) {
                          this.coursesEnrolled = new ArrayList<>(courses);
                      } else {
                          List<Course> oldCourses = getCoursesTeached();
              Severity: Minor
              Found in app/src/main/java/ch/epfl/sweng/studyup/player/Player.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

              Severity
              Category
              Status
              Source
              Language