nheyek/SDP-2018

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

Summary

Maintainability
B
6 hrs
Test Coverage

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

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

    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

        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

          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_add_edit_question);
              setupToolbar(this);

      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