SDPepe/AppArt

View on GitHub

Showing 33 of 101 total issues

File FirestoreAdHelper.java has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package ch.epfl.sdp.appart.database.firestoreservicehelpers;

import android.net.Uri;
import android.util.Log;
import android.util.Pair;

    AppUser has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class AppUser implements User {
    
        /* user attributes */
        private final String userId;
        private String name;
    Severity: Minor
    Found in app/src/main/java/ch/epfl/sdp/appart/user/AppUser.java - About 2 hrs to fix

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

          @Override
          public void onBindViewHolder(@NonNull PlaceViewHolder holder,
                                       int position) {
              Pair<PlaceOfInterest, Float> placeAndDistance = places.get(position);
              PlaceOfInterest place = placeAndDistance.first;
      Severity: Major
      Found in app/src/main/java/ch/epfl/sdp/appart/place/PlaceAdapter.java - About 2 hrs to fix

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

            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_scrolling);
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
        Severity: Major
        Found in app/src/main/java/ch/epfl/sdp/appart/ScrollingActivity.java - About 2 hrs to fix

          Method getResult has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private void getResult(CompletableFuture<String> rawResult,
                                     CompletableFuture<List<PlaceOfInterest>> result) {
                  //parse the Json String to a JSONArray to work with
                  CompletableFuture<JSONArray> queriesResults =
                          rawResult.thenCompose(this::parseRawResults);
          Severity: Minor
          Found in app/src/main/java/ch/epfl/sdp/appart/place/PlaceService.java - About 2 hrs to fix

            Method onBindViewHolder has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                @Override
                public void onBindViewHolder(@NonNull PlaceViewHolder holder,
                                             int position) {
                    Pair<PlaceOfInterest, Float> placeAndDistance = places.get(position);
                    PlaceOfInterest place = placeAndDistance.first;
            Severity: Minor
            Found in app/src/main/java/ch/epfl/sdp/appart/place/PlaceAdapter.java - About 1 hr 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 setupMap has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private void setupMap() {
                    SupportMapFragment mapFragment =
                            (SupportMapFragment) getSupportFragmentManager()
                                    .findFragmentById(R.id.map);
                    mapFragment.getView().setContentDescription("WAITING");
            Severity: Minor
            Found in app/src/main/java/ch/epfl/sdp/appart/MapActivity.java - About 1 hr to fix

              Method removeStaleAds has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private CompletableFuture<Void> removeStaleAds() {
              
                      if (!DatabaseSync.areWeOnline(this)) {
                          return CompletableFuture.completedFuture(null);
                      }
              Severity: Minor
              Found in app/src/main/java/ch/epfl/sdp/appart/FavoriteActivity.java - About 1 hr to fix

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

                    @Override
                    public View getInfoContents(Marker marker) {
                        View v = activity.getLayoutInflater().inflate(R.layout.map_info_layout,
                                null);
                        TextView cityTextView =
                Severity: Minor
                Found in app/src/main/java/ch/epfl/sdp/appart/map/ApartmentInfoWindow.java - About 1 hr to fix

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

                      @Override
                      protected void onCreate(Bundle savedInstanceState) {
                          super.onCreate(savedInstanceState);
                          setContentView(R.layout.activity_announce);
                  
                  
                  Severity: Minor
                  Found in app/src/main/java/ch/epfl/sdp/appart/AdActivity.java - About 1 hr to fix

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

                        @NotNull
                        @NonNull
                        public CompletableFuture<Ad> getAd(String adId) {
                            CompletableFuture<Ad> result = new CompletableFuture<>();
                    
                    

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

                          private CompletableFuture<List<Pair<PlaceOfInterest, Float>>> computeDistances(CompletableFuture<List<PlaceOfInterest>> placesFuture, Location location) {
                              CompletableFuture<List<Pair<PlaceOfInterest, Float>>> result =
                                      new CompletableFuture<>();
                              placesFuture.thenAccept(placesOfInterests -> {
                      
                      
                      Severity: Minor
                      Found in app/src/main/java/ch/epfl/sdp/appart/place/PlaceService.java - About 1 hr to fix

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

                            private void loadImage() {
                                PLSphericalPanorama panorama = new PLSphericalPanorama();
                        
                                CompletableFuture<Bitmap> bitmapFuture = new CompletableFuture<>();
                                if(isLocal) {
                        Severity: Minor
                        Found in app/src/main/java/ch/epfl/sdp/appart/PanoramaActivity.java - About 1 hr to fix

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

                              private void updatePhotos(Pair<List<String>, Boolean> referencesAndIsLocal) {
                                  LinearLayout horizontalLayout =
                                          findViewById(R.id.horizontal_children_Ad_linearLayout);
                                  horizontalLayout.removeAllViews();
                                  List<String> references = referencesAndIsLocal.first;
                          Severity: Minor
                          Found in app/src/main/java/ch/epfl/sdp/appart/AdActivity.java - About 1 hr to fix

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

                                public static Address makeAddress(String address) {
                            
                                    String filteredAddress = address.trim();
                                    String[] split = filteredAddress.split(",");
                                    Matcher streetMatcher = streetPattern.matcher(split[0].trim());

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

                              package ch.epfl.sdp.appart.database.firebaselayout;
                              
                              /**
                               * Un-instantiable Holder for the layout of the fields for a User on Firestore.
                               */
                              app/src/main/java/ch/epfl/sdp/appart/database/firebaselayout/CardLayout.java on lines 1..52

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

                              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

                              package ch.epfl.sdp.appart.database.firebaselayout;
                              
                              /**
                               * Un-instantiable Holder for the layout of the fields for a Card on Firestore.
                               */
                              app/src/main/java/ch/epfl/sdp/appart/database/firebaselayout/UserLayout.java on lines 1..53

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

                              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

                              Method uploadAdFromReferences has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  private CompletableFuture<Void> uploadAdFromReferences(Ad ad, DocumentReference adRef,
                                                             DocumentReference cardRef, StorageReference imagesRef,
                                                             List<String> picturesReferences, List<String> panoramasReferences) {

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

                                    @Override
                                    public boolean equals(Object o) {
                                        if (this == o) return true;
                                        if (o == null || getClass() != o.getClass()) return false;
                                        Address address = (Address) o;
                                Severity: Minor
                                Found in app/src/main/java/ch/epfl/sdp/appart/location/place/address/Address.java - About 45 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

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

                                    @NonNull
                                    @Override
                                    public CompletableFuture<Boolean> putImage(Uri uri, String imagePathAndName) {
                                        CompletableFuture<Boolean> result = new CompletableFuture<>();
                                        if (imagePathAndName == null){
                                app/src/main/java/ch/epfl/sdp/appart/database/MockDatabaseService.java on lines 208..219

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

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language