Showing 56 of 120 total issues
Method setupIngredientAutocomplete
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void setupIngredientAutocomplete(AutoCompleteTextView ingredientAutoComplete, Map<String, Integer> idMap, IngredientAutocomplete apiService){
ingredientAutoComplete.setThreshold(1);
final BooleanWrapper optionSelected = new BooleanWrapper(false);
ingredientAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() {
Method getNutritionFromIngredient
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void getNutritionFromIngredient(int id, Ingredient ingredient, Map<Integer, Boolean> finishedMap, UploadCallback callback){
//System.out.println(service.getNutrition(id, ingredient.getUnit().getValue(), API_KEY).request().url().toString());
//To be able to get the nutrition correctly for a given unit, we need a naming convention for the units which I am not sure how to do
//TODO give the users possible options of units once he chooses an ingredient?
Method onCreateView
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_upload_recipes, container, false);
Method popUpDialogBuilder
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressLint("ResourceAsColor")
private void popUpDialogBuilder(String[] items, boolean[] checksum, String title, List<Integer> selected, int filter){
AlertDialog.Builder builder= new AlertDialog.Builder(getContext(),R.style.AlertDialogTheme);
builder.setTitle(title);
builder.setCancelable(false);
Method filterLanguage
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static String filterLanguage(String input) {
if (input == null || input.isEmpty()) {
return input;
}
String s = filterLeetSpeach(input).toLowerCase().replaceAll("[^a-z]", " ");
- 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 equals
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
@Override
public boolean equals(Object obj) {
if (obj instanceof Comment) {
if (likes != ((Comment)obj).likes
|| !content.equals(((Comment)obj).content)) {
- 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 onMapReady
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressLint("MissingPermission")
@Override
public void onMapReady(@NonNull GoogleMap googleMap) {
googleMap.setOnInfoWindowClickListener(this);
Method onCheckedChanged
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int position = getAdapterPosition();
Comment currentComment = adapter.getData().get(position);
if (isChecked) {
Method getNearby
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public Task<List<Pair<String, Location>>> getNearby(Location location) {
FirebaseUser user = FirebaseInstanceManager.getAuth().getCurrentUser();
if (user == null) {
return Tasks.forException(new UserNotAuthenticatedException("User needs to be authenticated to store location"));
}
Method onSignInResult
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void onSignInResult(FirebaseAuthUIAuthenticationResult result) {
IdpResponse response = result.getIdpResponse();
if (result.getResultCode() == RESULT_OK) {
// Successfully signed in
FirebaseUser user = FirebaseInstanceManager.getAuth().getCurrentUser();
Method fetchRecipeList
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public List<String> fetchRecipeList(){
//String will represent the ID of the recipe, for now it's just the name
Map<String, Float> mapOfRecipes = new HashMap<>();
for(Recipe r :allRecipes){
Method handleMessage
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@Override
public void handleMessage(Message msg) {
synchronized (CountDownTimerWithPause.this) {
if (!paused) {
final long millisLeft = stopTimeInFuture - getRealTime();
- 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 isStepValid
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public boolean isStepValid() {
for (int i = 0; i < stepListLinearLayout.getChildCount(); i++) {
if (stepListLinearLayout.getChildAt(i) instanceof ConstraintLayout) {
ConstraintLayout step = (ConstraintLayout) stepListLinearLayout.getChildAt(i);
if (step.getChildAt(0) instanceof TextInputLayout) {
- 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 addIngredient
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void addIngredient(Map<String, Integer> idMap, IngredientAutocomplete apiService, boolean offerable, List<String> prefill) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
final View ingredient = inflater.inflate(R.layout.recipe_ingredient_edittext, null, false);
ImageView removeIngredient = (ImageView) ingredient.findViewById(R.id.removeIngredient);
ImageView offerIngredient = (ImageView) ingredient.findViewById(R.id.offerIngredientItem);
Method filterComment
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static Comment filterComment(Comment comment, boolean filterLanguage) {
if (filterLanguage) {
String filtered = filterLanguage(comment.getContent());
if (comment.getReplies().size() == 0) {
return new Comment(comment.getLikes(), filtered, new LinkedList<>());
- 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 onCheckedChanged
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
// Add the recipe to favorites
Method onCreateView
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
manager = new ShoppingListManager(getContext());
Method onInfoWindowClick
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void onInfoWindowClick(@NonNull Marker marker) {
Pair<String, Ingredient> offer = offers.get(marker);
FirebaseUser user = FirebaseInstanceManager.getAuth().getCurrentUser();
Method setCommentContents
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void setCommentContents(RecyclerView commentsList) {
commentsList.setLayoutManager(new LinearLayoutManager(this));
for(Comment c : recipe.comments){
c.setContent(LanguageFilter.filterLanguage(c.getContent()));
Method onCreate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recipe);