nheyek/SDP-2018

View on GitHub
app/src/main/java/ch/epfl/sweng/studyup/questions/DisplayQuestionActivity.java

Summary

Maintainability
C
1 day
Test Coverage

File DisplayQuestionActivity.java has 349 lines of code (exceeds 250 allowed). Consider refactoring.
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

    public class DisplayQuestionActivity extends RefreshContext {
    
        @SuppressWarnings("HardCodedStringLiteral")
        private final String TAG = "DisplayQuestionActivity";
        @SuppressWarnings("HardCodedStringLiteral")

      Consider simplifying this complex logical expression.
      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

            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();

        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

            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();

        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

        There are no issues that match your filters.

        Category
        Status