app/src/main/java/ch/epfl/sweng/studyup/questions/DisplayQuestionActivity.java
File DisplayQuestionActivity.java
has 349 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
package ch.epfl.sweng.studyup.questions;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.PendingIntent;
DisplayQuestionActivity
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
Open
public class DisplayQuestionActivity extends RefreshContext {
@SuppressWarnings("HardCodedStringLiteral")
private final String TAG = "DisplayQuestionActivity";
@SuppressWarnings("HardCodedStringLiteral")
Consider simplifying this complex logical expression. Open
Open
if (!intent.hasExtra(DISPLAY_QUESTION_TITLE) || !intent.hasExtra(DISPLAY_QUESTION_ID) || !intent.hasExtra(DISPLAY_QUESTION_ANSWER)
|| !intent.hasExtra(DISPLAY_QUESTION_TRUE_FALSE) || !intent.hasExtra(DISPLAY_QUESTION_LANG) || !intent.hasExtra(DISPLAY_QUESTION_DURATION)) {
quit(); return false;
}
Method handleTimedQuestion
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
private void handleTimedQuestion(Question displayQuestion) {
String questionId = displayQuestion.getQuestionId();
TextView time_left = findViewById(R.id.time_left); ImageView alarm = findViewById(R.id.alarmImage);
long now = System.currentTimeMillis(); String displayedText;
long duration = displayQuestion.getDuration();
- 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 answerQuestion
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public void answerQuestion(View view) {
int chkTOP = answerGroupTOP.getCheckedRadioButtonId();
int chkBOT = answerGroupBOT.getCheckedRadioButtonId();
if(Player.get().getAnsweredQuestion().containsKey(displayQuestion.getQuestionId())) {
Toast.makeText(this, getString(R.string.text_cantanswertwice), Toast.LENGTH_SHORT).show();
- 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"