samuelchassot/SDP-SwissTeam

View on GitHub

Showing 27 of 80 total issues

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

public class DBUtility {

    public final static String USERS = "Users";
    public final static String CATEGORIES = "Categories";
    public final static String POSTS = "Posts";
Severity: Minor
Found in app/src/main/java/ch/epfl/swissteam/services/providers/DBUtility.java - About 5 hrs to fix

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

    public class User implements DBSavable {
    
        public static String DELETED_USER_NAME = "Deleted user";
        public static String DELETED_USER_IMG_URL = "https://cdn.pixabay.com/photo/2014/03/25/15/19/cross-296507_960_720.png";
    
    
    Severity: Minor
    Found in app/src/main/java/ch/epfl/swissteam/services/models/User.java - About 3 hrs to fix

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

      public class SettingsFragment extends Fragment implements OnMapReadyCallback {
      
          private static final String MAPVIEW_BUNDLE_KEY = "MapViewBundleKey";
          private static final double KILOMETER_TO_METER_FACTOR = 1000.0;
      
      

        Method removeFromDB has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public void removeFromDB(DatabaseReference db) throws Utils.IllegalCallException {
                //remove the user's entry
                db.child(DBUtility.USERS).child(googleId_).removeValue();
        
        
        Severity: Minor
        Found in app/src/main/java/ch/epfl/swissteam/services/models/User.java - About 2 hrs 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 onCreateView has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                                     Bundle savedInstanceState) {
                View view = inflater.inflate(R.layout.fragment_services, container, false);
        
        

          File User.java has 265 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package ch.epfl.swissteam.services.models;
          
          import android.util.Log;
          
          import com.google.firebase.database.DatabaseReference;
          Severity: Minor
          Found in app/src/main/java/ch/epfl/swissteam/services/models/User.java - About 2 hrs to fix

            File DBUtility.java has 261 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            package ch.epfl.swissteam.services.providers;
            
            import android.app.Activity;
            import android.location.Location;
            import android.support.annotation.NonNull;
            Severity: Minor
            Found in app/src/main/java/ch/epfl/swissteam/services/providers/DBUtility.java - About 2 hrs to fix

              Method loadAndShowUser has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private void loadAndShowUser(String clientUniqueID) {
                      //for now we use the username
                      DBUtility.get().getUser(clientUniqueID, (user) -> {
                          user_ = user;
              
              

                Method onCreate has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Method removeFromDB has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      @Override
                      public void removeFromDB(DatabaseReference db) throws Utils.IllegalCallException {
                          //remove the user's entry
                          db.child(DBUtility.USERS).child(googleId_).removeValue();
                  
                  
                  Severity: Minor
                  Found in app/src/main/java/ch/epfl/swissteam/services/models/User.java - About 1 hr to fix

                    Method notifyNewMessages has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public void notifyNewMessages(Activity activity, String googleId) {
                            if (!isNotificationsSetupDone && googleId != null) {
                                db_.child(USERS).child(googleId).child("chatRelations_").addChildEventListener(new ChildEventListener() {
                                    @Override
                                    public void onChildAdded(@NonNull DataSnapshot relationDataSnapshot, @Nullable String s) {

                      Method onCreateView has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          @Override
                          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                                   Bundle savedInstanceState) {
                              View frag = inflater.inflate(R.layout.fragment_create_post, container, false);
                              ((Button) frag.findViewById(R.id.button_createpostfragment_send)).setOnClickListener(this);

                        Method onCreate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            @Override
                            protected void onCreate(Bundle savedInstanceState) {
                                super.onCreate(savedInstanceState);
                        
                        
                        

                          Method onClick has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              @Override
                              public void onClick(View v) {
                          
                                  EditText titleField = ((EditText) getView().findViewById(R.id.plaintext_createpostfragment_title));
                                  EditText bodyField = ((EditText) getView().findViewById(R.id.plaintext_createpostfragment_body));

                            Method updateMapView has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private void updateMapView() {
                                    Location currentLocation = LocationManager.get().getCurrentLocation_();
                            
                                    if(currentLocation != null) {
                                        //Move camera to the current location

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

                                  private void initDataSet(Categories category, ArrayList<String> keywords) {
                                      ActivityUtils.hideKeyboard(this.getActivity());
                                      View view = getView();
                                      if (category == Categories.ALL) {
                                          DBUtility.get().getAllUsers((usersdb -> {

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

                                    @Override
                                    public void onBindViewHolder(UserViewHolder holder, int i) {
                                        holder.nameView_.setText(users_.get(i).getName_());
                                        holder.bodyView_.setText(users_.get(i).getDescription_());
                                        int rating = users_.get(i).getRating_();

                                  Method onCreate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      @Override
                                      protected void onCreate(Bundle savedInstanceState) {
                                          super.onCreate(savedInstanceState);
                                          setContentView(R.layout.activity_new_profile_details);
                                          findViewById(R.id.imageview_newprofiledetails_picture).setTag(R.string.general_next);

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

                                        public void chooseFragment(int id) {
                                            switch (id) {
                                                case (R.id.button_maindrawer_home):
                                                    showHomeFragment();
                                                    break;

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

                                          @Override
                                          public void onClick(View v) {
                                      
                                              EditText titleField = ((EditText) getView().findViewById(R.id.plaintext_createpostfragment_title));
                                              EditText bodyField = ((EditText) getView().findViewById(R.id.plaintext_createpostfragment_body));

                                      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