Showing 23 of 101 total issues
File FirestoreAdHelper.java
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
Open
public class AppUser implements User {
/* user attributes */
private final String userId;
private String name;
Method onBindViewHolder
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public void onBindViewHolder(@NonNull PlaceViewHolder holder,
int position) {
Pair<PlaceOfInterest, Float> placeAndDistance = places.get(position);
PlaceOfInterest place = placeAndDistance.first;
Method onCreate
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
Method getResult
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
Method onBindViewHolder
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
@Override
public void onBindViewHolder(@NonNull PlaceViewHolder holder,
int position) {
Pair<PlaceOfInterest, Float> placeAndDistance = places.get(position);
PlaceOfInterest place = placeAndDistance.first;
- Read upRead up
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
Open
private void setupMap() {
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getView().setContentDescription("WAITING");
Method removeStaleAds
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private CompletableFuture<Void> removeStaleAds() {
if (!DatabaseSync.areWeOnline(this)) {
return CompletableFuture.completedFuture(null);
}
Method getInfoContents
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
public View getInfoContents(Marker marker) {
View v = activity.getLayoutInflater().inflate(R.layout.map_info_layout,
null);
TextView cityTextView =
Method onCreate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_announce);
Method getAd
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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 -> {
Method loadImage
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void loadImage() {
PLSphericalPanorama panorama = new PLSphericalPanorama();
CompletableFuture<Bitmap> bitmapFuture = new CompletableFuture<>();
if(isLocal) {
Method updatePhotos
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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;
Method makeAddress
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static Address makeAddress(String address) {
String filteredAddress = address.trim();
String[] split = filteredAddress.split(",");
Matcher streetMatcher = streetPattern.matcher(split[0].trim());
Method equals
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Address address = (Address) o;
- Read upRead up
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 uploadAdFromReferences
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private CompletableFuture<Void> uploadAdFromReferences(Ad ad, DocumentReference adRef,
DocumentReference cardRef, StorageReference imagesRef,
List<String> picturesReferences, List<String> panoramasReferences) {
Method onResourceReady
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public boolean onResourceReady(Drawable resource,
Object model,
Target<Drawable> target,
DataSource dataSource,
boolean isFirstResource) {
Method uploadCardFromReferences
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private CompletableFuture<Void> uploadCardFromReferences(Ad ad, DocumentReference adRef,
DocumentReference cardRef, StorageReference imagesRef,
String firstImageRef) {
Avoid too many return
statements within this method. Open
Open
return null;