nheyek/SDP-2018

View on GitHub

Showing 58 of 124 total issues

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

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = View.inflate(cnx, idLayout, null);
            }

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

          public void addRequest(final String course, final String sciper, final String firstname, final String lastname) {
              CourseRequest request = new CourseRequest(Course.valueOf(course), sciper, firstname, lastname);
              if(!requests.contains(request))
                  requests.add(request);
              setupListViews();

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

            @Test
            public void editTrueFalseQuestionAnswerImagedToTextBasedTest() throws Throwable {
                q = new Question(questionUUID, this.getClass().getName(), true, 0, Constants.Course.SWENG.name(), "en");
                mActivityRule.launchActivity(new Intent().putExtra(AddOrEditQuestionActivity.class.getSimpleName(), q));
        
        

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

              @Test
              public void updateScheduleTest(){
                  Player.get().setRole(Constants.Role.student);
                  mActivityRule.launchActivity(new Intent());
                  Utils.waitAndTag(1000, "ScheduleActivityStudentTest");

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

                @Test
                public void updateScheduleTest() {
                    mActivityRule.launchActivity(new Intent().putExtra(COURSE_NAME_INTENT_SCHEDULE, Constants.Course.FakeCourse.name()));
                    waitAndTag(1000, "ScheduleActivityTeacherTest");
            
            

              Method loadUsers has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static void loadUsers(final Callback callback) {
                      final List<UserData> userList = new ArrayList<>();
              
                      Firestore.get().getDb().collection(FB_USERS).get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                          @Override
              Severity: Minor
              Found in app/src/main/java/ch/epfl/sweng/studyup/utils/StatsUtils.java - About 1 hr to fix

                Method loadInterface has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private void loadInterface() {
                        // User picture
                        ImageButton pic_button = findViewById(R.id.pic_btn);
                        pic_button2 = findViewById(R.id.pic_btn2);
                        image_view = findViewById(R.id.pic_imageview);
                Severity: Minor
                Found in app/src/main/java/ch/epfl/sweng/studyup/player/HomeActivity.java - About 1 hr to fix

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

                      @Override
                      protected void onCreate(Bundle savedInstanceState) {
                          super.onCreate(savedInstanceState);
                          setContentView(R.layout.activity_add_edit_question);
                          setupToolbar(this);

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

                      @SuppressWarnings("unchecked")
                      public void updateLocalDataFromRemote(Map<String, Object> remotePlayerData) {
                  
                          if (remotePlayerData.isEmpty()) {
                              Log.e(TAG,"Unable to retrieve player data from Firebase.");
                  Severity: Minor
                  Found in app/src/main/java/ch/epfl/sweng/studyup/player/Player.java - About 1 hr to fix

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

                        public void selectImage(View v) {
                            String col = getSharedPreferences(USER_PREFS, MODE_PRIVATE)
                                    .getString(COLOR_SETTINGS_KEYWORD, SETTINGS_COLOR_RED);
                            AlertDialog.Builder dialogBuilder = col.equals(SETTINGS_COLOR_DARK) ?
                                    new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_DARK) : new AlertDialog.Builder(this);
                    Severity: Minor
                    Found in app/src/main/java/ch/epfl/sweng/studyup/player/CustomActivity.java - About 1 hr to fix

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

                          private void editAndCheckQuestionHelper(final int newAnswerNumber, final boolean changeType, final boolean isTrueFalseBeforeEdition) throws Throwable {
                              mActivityRule.runOnUiThread(new Runnable() {
                                  @Override
                                  public void run() {
                                      mActivityRule.getActivity().findViewById(R.id.addOrEditQuestionButton).callOnClick();

                        Method setupListViews has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public void setupListViews(){
                                List<Course> otherCourses = new ArrayList<>(Arrays.asList(Course.values()));
                                otherCourses.remove(FakeCourse);
                                if(MOCK_ENABLED) otherCourses = new ArrayList<>(Arrays.asList(FakeCourse));
                        
                        

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

                            @Override
                            public void onActivityResult(int requestCode, int resultCode, Intent data) {
                        
                                super.onActivityResult(requestCode, resultCode, data);
                                if (resultCode == RESULT_CANCELED) {
                        Severity: Minor
                        Found in app/src/main/java/ch/epfl/sweng/studyup/player/CustomActivity.java - About 55 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 getStudentRankingsForCourse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static List<Pair<String, Integer>> getStudentRankingsForCourse(List<UserData> studentsInCourse, final List<String> courseQuestionIds) {
                        
                                List<Pair<String, Integer>> studentRankings = new ArrayList<>();
                        
                                for (UserData student : studentsInCourse) {
                        Severity: Minor
                        Found in app/src/main/java/ch/epfl/sweng/studyup/utils/StatsUtils.java - About 55 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 onLocationUpdate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public void onLocationUpdate(LatLng latLong) {
                                if (latLong != null) {
                                    Log.d("GPS_MAP", "New position map: " + latLong.toString());
                                    if (mMap != null) {
                                        if (location != null) {
                        Severity: Minor
                        Found in app/src/main/java/ch/epfl/sweng/studyup/map/MapsActivity.java - About 55 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 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            @Override
                            protected void onCreate(Bundle savedInstanceState) {
                                super.onCreate(savedInstanceState);
                                setContentView(R.layout.activity_course_selection);
                        
                        

                        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 setupWeekView has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public static void setupWeekView(WeekView weekView,
                                                                   WeekView.EventLongPressListener eventLongPressListener,
                                                                   DateTimeInterpreter dateTimeInterpreter,
                                                                   MonthLoader.MonthChangeListener monthChangeListener,
                                                                   WeekView.EventClickListener eventClickListener,
                        Severity: Minor
                        Found in app/src/main/java/ch/epfl/sweng/studyup/utils/Utils.java - About 45 mins to fix

                          Method equals has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  @Override
                                  public boolean equals(Object o){
                                      if(o == null || !(o instanceof CourseRequest)) {
                                          return false;
                                      } else {

                          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

                          Consider simplifying this complex logical expression.
                          Open

                                  if (!intent.hasExtra(DISPLAY_QUESTION_TITLE) || !intent.hasExtra(DISPLAY_QUESTION_ID) || !intent.hasExtra(DISPLAY_QUESTION_ANSWER)
                                          || !intent.hasExtra(DISPLAY_QUESTION_TRUE_FALSE) || !intent.hasExtra(DISPLAY_QUESTION_LANG) || !intent.hasExtra(DISPLAY_QUESTION_DURATION)) {
                                      quit(); return false;
                                  }
                            Severity
                            Category
                            Status
                            Source
                            Language