File FavorDetailView.java
has 308 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
package ch.epfl.sweng.favors.favors;
import android.arch.lifecycle.ViewModelProviders;
import android.databinding.BindingAdapter;
import android.databinding.DataBindingUtil;
Method onCreateView
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_favor_detail_view, container, false);
binding.setElements(this);
Method onComplete
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
@Override
public void onComplete(@NonNull Task task) {
if (interestedPeople.contains(User.getMain().getId())) {
sendMessage(localFavor.get(Favor.StringFields.ownerID), "Sorry, I'm not anymore interested in your favor : " + localFavor.get(Favor.StringFields.title));
interestedPeople.remove(User.getMain().getId());
Method paySelectedPeople
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
public void paySelectedPeople(ArrayList<String> selectedUsers) {
long tokenPerPerson = localFavor.get(Favor.LongFields.tokenPerPerson);
if (selectedUsers.size() == 0) {
Method updateInterestedUsersNames
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Wontfix
private void updateInterestedUsersNames(Favor favor){
if (favor.get(Favor.ObjectFields.interested) != null && favor.get(Favor.ObjectFields.interested) instanceof ArrayList) {
interestedPeople = (ArrayList<String>) favor.get(Favor.ObjectFields.interested);
userNames = new HashMap<>();
//TODO: favor.getRef(Favor.ObjectFields.interested) and set a listener;
- 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 onCreate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Wontfix
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
userNames = new HashMap<>();
- 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 paySelectedPeople
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Wontfix
public void paySelectedPeople(ArrayList<String> selectedUsers) {
long tokenPerPerson = localFavor.get(Favor.LongFields.tokenPerPerson);
if (selectedUsers.size() == 0) {
- 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
Avoid too many return
statements within this method. Wontfix
return binding.getRoot();