maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java

Summary

Maintainability
F
5 days
Test Coverage

File MaoniActivity.java has 513 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2016-2022 Armel Soro
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
Severity: Major
Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - About 1 day to fix

    Method onCreate has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        protected void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
    
    
    Severity: Minor
    Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - About 7 hrs to fix

    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 onCreate has 147 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        protected void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
    
    
    Severity: Major
    Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - About 5 hrs to fix

      Method initScreenCaptureView has 114 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void initScreenCaptureView(@NonNull final Intent intent) {
              final ImageButton screenshotThumb = findViewById(R.id.maoni_screenshot);
      
              final TextView touchToPreviewTextView = findViewById(R.id.maoni_screenshot_touch_to_preview);
              if (touchToPreviewTextView != null && intent.hasExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)) {
      Severity: Major
      Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - About 4 hrs to fix

        Method initScreenCaptureView has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            private void initScreenCaptureView(@NonNull final Intent intent) {
                final ImageButton screenshotThumb = findViewById(R.id.maoni_screenshot);
        
                final TextView touchToPreviewTextView = findViewById(R.id.maoni_screenshot_touch_to_preview);
                if (touchToPreviewTextView != null && intent.hasExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)) {
        Severity: Minor
        Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - About 4 hrs to fix

        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 validateAndSubmitForm has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            private void validateAndSubmitForm() {
                //Validate form
                if (this.validateForm(mRootView)) {
                    //TODO Check that device is actually connected to the internet prior to going any further
                    boolean includeScreenshot = false;
        Severity: Minor
        Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - About 4 hrs to fix

        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 validateAndSubmitForm has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private void validateAndSubmitForm() {
                //Validate form
                if (this.validateForm(mRootView)) {
                    //TODO Check that device is actually connected to the internet prior to going any further
                    boolean includeScreenshot = false;
        Severity: Major
        Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - About 2 hrs to fix

          Method validateForm has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              private boolean validateForm(@NonNull View rootView) {
                  if (mContent != null) {
                      if (TextUtils.isEmpty(mContent.getText())) {
                          if (mContentInputLayout != null) {
                              mContentInputLayout.setErrorEnabled(true);
          Severity: Minor
          Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - About 1 hr to fix

          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

          TODO found
          Open

                      //TODO Check that device is actually connected to the internet prior to going any further

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                  if (intent.hasExtra(MESSAGE)) {
                      final CharSequence message = intent.getCharSequenceExtra(MESSAGE);
                      final TextView activityMessageTv = findViewById(R.id.maoni_feedback_message);
                      if (activityMessageTv != null) {
                          activityMessageTv.setText(message);
          Severity: Minor
          Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java and 1 other location - About 45 mins to fix
          maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java on lines 274..280

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 54.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                  if (intent.hasExtra(SCREENSHOT_HINT)) {
                      final CharSequence screenshotInformationalHint = intent.getCharSequenceExtra(SCREENSHOT_HINT);
                      final TextView screenshotInformationalHintTv = findViewById(R.id.maoni_screenshot_informational_text);
                      if (screenshotInformationalHintTv != null) {
                          screenshotInformationalHintTv.setText(screenshotInformationalHint);
          Severity: Minor
          Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java and 1 other location - About 45 mins to fix
          maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java on lines 266..272

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 54.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                      } else {
                          if (mIncludeScreenshot != null) {
                              mIncludeScreenshot.setVisibility(View.GONE);
                          }
                          if (screenshotContentView != null) {
          Severity: Minor
          Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java and 1 other location - About 30 mins to fix
          maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java on lines 540..547

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 42.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                  } else {
                      if (mIncludeScreenshot != null) {
                          mIncludeScreenshot.setVisibility(View.GONE);
                      }
                      if (screenshotContentView != null) {
          Severity: Minor
          Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java and 1 other location - About 30 mins to fix
          maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java on lines 532..539

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 42.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                  for (final Integer logsCapturingRelatedField : logsCapturingRelatedFields) {
                      final View view = findViewById(logsCapturingRelatedField);
                      if (view == null) {
                          continue;
                      }
          Severity: Minor
          Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java and 1 other location - About 30 mins to fix
          maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java on lines 322..328

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 40.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

                  for (final Integer screenCapturingRelatedField : screenCapturingRelatedFields) {
                      final View view = findViewById(screenCapturingRelatedField);
                      if (view == null) {
                          continue;
                      }
          Severity: Minor
          Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java and 1 other location - About 30 mins to fix
          maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java on lines 336..342

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 40.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status