Showing 80 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";
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";
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();
- 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 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;
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;
Similar blocks of code found in 2 locations. Consider refactoring. Open
@Test
public void searchNothingDisplaysAll(){
Espresso.closeSoftKeyboard();
String text = "";
onView(withId(R.id.online_chat_fragment_search_bar)).perform(typeText(text), closeSoftKeyboard()).check(matches(withText(text)));
- 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 137.
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
@Test
public void searchForExistentDisplaysSearch(){
Espresso.closeSoftKeyboard();
String text = "Ra";
onView(withId(R.id.online_chat_fragment_search_bar)).perform(typeText(text), closeSoftKeyboard()).check(matches(withText(text)));
- 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 137.
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 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);
Identical blocks of code found in 2 locations. Consider refactoring. Open
static class PostViewHolder extends RecyclerView.ViewHolder {
protected FrameLayout frameLayout_;
protected TextView titleView_;
protected TextView bodyView_;
protected ImageButton editButton_;
- 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 112.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
static class PostViewHolder extends RecyclerView.ViewHolder {
protected TextView titleView_;
protected TextView bodyView_;
protected TextView distanceView_;
- 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 112.
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 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();
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 -> {