app/src/main/java/ch/epfl/sweng/studyup/questions/AddOrEditQuestionActivity.java
File AddOrEditQuestionActivity.java
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
package ch.epfl.sweng.studyup.questions;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
Method addQuestion
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
public void addQuestion(View current) {
RadioGroup imageTextRadioGroup = findViewById(R.id.text_or_image_radio_group), trueFalseRadioGroup = findViewById(R.id.true_false_or_mcq_radio_group);
if (!(imageURI != null || bitmap != null || imageTextRadioGroup.getCheckedRadioButtonId() == R.id.text_radio_button)) return;
RadioGroup answerGroup = findViewById(R.id.question_radio_group);
RadioButton checkedButton = findViewById(answerGroup.getCheckedRadioButtonId());
- 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 addQuestion
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void addQuestion(View current) {
RadioGroup imageTextRadioGroup = findViewById(R.id.text_or_image_radio_group), trueFalseRadioGroup = findViewById(R.id.true_false_or_mcq_radio_group);
if (!(imageURI != null || bitmap != null || imageTextRadioGroup.getCheckedRadioButtonId() == R.id.text_radio_button)) return;
RadioGroup answerGroup = findViewById(R.id.question_radio_group);
RadioButton checkedButton = findViewById(answerGroup.getCheckedRadioButtonId());
Method onCreate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_edit_question);
setupToolbar(this);
- 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"