Swati4star/Images-to-PDF

View on GitHub
app/src/main/java/swati4star/createpdf/fragment/ImageToPdfFragment.java

Summary

Maintainability
F
4 days
Test Coverage

File ImageToPdfFragment.java has 704 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package swati4star.createpdf.fragment;

import static swati4star.createpdf.util.Constants.DEFAULT_BORDER_WIDTH;
import static swati4star.createpdf.util.Constants.DEFAULT_COMPRESSION;
import static swati4star.createpdf.util.Constants.DEFAULT_IMAGE_BORDER_TEXT;

    ImageToPdfFragment has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class ImageToPdfFragment extends Fragment implements OnItemClickListener,
            OnPDFCreatedInterface {
        private static final int INTENT_REQUEST_APPLY_FILTER = 10;
        private static final int INTENT_REQUEST_PREVIEW_IMAGE = 11;
        private static final int INTENT_REQUEST_REARRANGE_IMAGE = 12;

      Method onActivityResult has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public void onActivityResult(int requestCode, int resultCode, Intent data) {
              super.onActivityResult(requestCode, resultCode, data);
              mIsButtonAlreadyClicked = false;
              if (resultCode != Activity.RESULT_OK || data == null)

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

          @Override
          public void onActivityResult(int requestCode, int resultCode, Intent data) {
              super.onActivityResult(requestCode, resultCode, data);
              mIsButtonAlreadyClicked = false;
              if (resultCode != Activity.RESULT_OK || data == null)

        Method addWatermark has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private void addWatermark() {
                final MaterialDialog dialog = new MaterialDialog.Builder(mActivity)
                        .title(R.string.add_watermark)
                        .customView(R.layout.add_watermark_dialog, true)
                        .positiveText(android.R.string.ok)

          Method onItemClick has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Override
              public void onItemClick(int position) {
          
                  if (mImagesUri.size() == 0) {
                      StringUtils.getInstance().showSnackbar(mActivity, R.string.snackbar_no_images);

            Method addPageNumbers has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private void addPageNumbers() {
            
                    SharedPreferences.Editor editor = mSharedPreferences.edit();
                    mPageNumStyle = mSharedPreferences.getString(Constants.PREF_PAGE_STYLE, null);
                    mChoseId = mSharedPreferences.getInt(Constants.PREF_PAGE_STYLE_ID, -1);

              Method passwordProtectPDF has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private void passwordProtectPDF() {
                      final MaterialDialog dialog = new MaterialDialog.Builder(mActivity)
                              .title(R.string.set_password)
                              .customView(R.layout.custom_dialog, true)
                              .positiveText(android.R.string.ok)

                Method checkForImagesInBundle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private void checkForImagesInBundle() {
                        Bundle bundle = getArguments();
                        if (bundle == null)
                            return;
                        if (bundle.getBoolean(OPEN_SELECT_IMAGES))
                Severity: Minor
                Found in app/src/main/java/swati4star/createpdf/fragment/ImageToPdfFragment.java - About 35 mins 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

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

                        positiveAction.setOnClickListener(v -> {
                            if (StringUtils.getInstance().isEmpty(passwordInput.getText())) {
                                StringUtils.getInstance().showSnackbar(mActivity, R.string.snackbar_password_cannot_be_blank);
                            } else {
                                mPdfOptions.setPassword(passwordInput.getText().toString());
                app/src/main/java/swati4star/createpdf/fragment/texttopdf/PasswordEnhancer.java on lines 62..71

                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 72.

                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 (checkedRadioButtonId == rbOpt1.getId()) {
                                        mPageNumStyle = Constants.PG_NUM_STYLE_PAGE_X_OF_N;
                                    } else if (checkedRadioButtonId == rbOpt2.getId()) {
                                        mPageNumStyle = Constants.PG_NUM_STYLE_X_OF_N;
                                    } else if (checkedRadioButtonId == rbOpt3.getId()) {
                app/src/main/java/swati4star/createpdf/fragment/SettingsFragment.java on lines 320..326

                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 66.

                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

                        final MaterialDialog dialog = new MaterialDialog.Builder(mActivity)
                                .title(R.string.set_password)
                                .customView(R.layout.custom_dialog, true)
                                .positiveText(android.R.string.ok)
                                .negativeText(android.R.string.cancel)
                app/src/main/java/swati4star/createpdf/fragment/ImageToPdfFragment.java on lines 577..583

                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 58.

                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

                        final MaterialDialog dialog = new MaterialDialog.Builder(mActivity)
                                .title(R.string.add_watermark)
                                .customView(R.layout.add_watermark_dialog, true)
                                .positiveText(android.R.string.ok)
                                .negativeText(android.R.string.cancel)
                app/src/main/java/swati4star/createpdf/fragment/ImageToPdfFragment.java on lines 532..538

                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 58.

                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

                        MaterialDialog materialDialog = new MaterialDialog.Builder(mActivity)
                                .title(R.string.choose_page_number_style)
                                .customView(dialogLayout, false)
                                .positiveText(R.string.ok)
                                .negativeText(R.string.cancel)
                app/src/main/java/swati4star/createpdf/fragment/SettingsFragment.java on lines 311..316

                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

                There are no issues that match your filters.

                Category
                Status