Showing 27 of 80 total issues
DBUtility
has 41 methods (exceeds 20 allowed). Consider refactoring. Open
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
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
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
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
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
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
Open
package ch.epfl.swissteam.services.providers;
import android.app.Activity;
import android.location.Location;
import android.support.annotation.NonNull;
Method loadAndShowUser
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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
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
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
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
Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Method onClick
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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
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
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
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
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
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));
- 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"