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;
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;
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);
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);
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;
- 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
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
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
@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
@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
@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 -> {
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) {
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;
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.
*/
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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.
*/
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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;
- 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
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){
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76