berict/Tapad

View on GitHub
app/src/main/java/com/bedrock/padder/activity/PresetStoreActivity.java

Summary

Maintainability
D
2 days
Test Coverage

File PresetStoreActivity.java has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package com.bedrock.padder.activity;

import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;

    PresetStoreActivity has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class PresetStoreActivity extends AppCompatActivity implements FileChooserDialog.FileCallback {
    
        private WindowHelper window = new WindowHelper();
        private AnimateHelper anim = new AnimateHelper();
        private ToolbarHelper toolbar = new ToolbarHelper();

      Method setViewPager has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void setViewPager() {
              if (hasPermission) {
                  Log.d(TAG, "setViewPager");
      
                  installedFragment = new PresetStoreInstalledFragment();

        Method onRequestPermissionsResult has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
                super.onRequestPermissionsResult(requestCode, permissions, grantResults);
                switch (requestCode) {
                    case REQUEST_WRITE_STORAGE:

          Method onCreate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            Method setDirectory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                private void setDirectory() {
                    // loading start
                    Log.d(TAG, "setDirectory");
                    if (!hasPermission) {
                        // no permission granted
            Severity: Minor
            Found in app/src/main/java/com/bedrock/padder/activity/PresetStoreActivity.java - About 45 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

            Method getCustomFolderName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                String getCustomFolderName() {
                    File files[] = new File(PROJECT_LOCATION_PRESETS).listFiles();
                    String folderName = getResources().getString(R.string.custom_preset_folder_name);
                    int fileNameCount = 0;
                    for (File folder : files) {
            Severity: Minor
            Found in app/src/main/java/com/bedrock/padder/activity/PresetStoreActivity.java - About 45 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

            Method onRequestPermissionsResult has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                @Override
                public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
                    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
                    switch (requestCode) {
                        case REQUEST_WRITE_STORAGE:
            Severity: Minor
            Found in app/src/main/java/com/bedrock/padder/activity/PresetStoreActivity.java - About 25 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

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

                    if (Build.VERSION.SDK_INT < 21) {
                        statusBar.setVisibility(View.GONE);
                    } else {
                        try {
                            statusBar.getLayoutParams().height = window.getStatusBarFromPrefs(activity);
            app/src/main/java/com/bedrock/padder/activity/AboutActivity.java on lines 85..94

            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 4 locations. Consider refactoring.
            Open

                void pressBack() {
                    KeyEvent kDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
                    activity.dispatchKeyEvent(kDown);
                    KeyEvent kUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK);
                    activity.dispatchKeyEvent(kUp);
            app/src/main/java/com/bedrock/padder/activity/AboutActivity.java on lines 214..219
            app/src/main/java/com/bedrock/padder/activity/ColorActivity.java on lines 155..160
            app/src/main/java/com/bedrock/padder/fragment/AboutFragment.java on lines 143..148

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

            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

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

                                new MaterialDialog.Builder(activity)
                                        .title(R.string.preset_store_permission_dialog_title)
                                        .titleColorRes(R.color.dark_primary)
                                        .content(R.string.preset_store_permission_dialog_text)
                                        .contentColorRes(R.color.dark_action)
            app/src/main/java/com/bedrock/padder/fragment/PresetStoreOnlineFragment.java on lines 187..192
            app/src/main/java/com/bedrock/padder/fragment/PresetStoreOnlineFragment.java on lines 251..256
            app/src/main/java/com/bedrock/padder/model/preset/store/Item.java on lines 173..178
            app/src/main/java/com/bedrock/padder/model/preset/store/Item.java on lines 350..355
            app/src/main/java/com/bedrock/padder/model/preset/store/Item.java on lines 464..469

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

            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

                    window.setMarginRelativePX(R.id.fab, 0, 0,
                            window.convertDPtoPX(20, activity),
                            window.getNavigationBarFromPrefs(activity) + window.convertDPtoPX(20, activity),
                            activity);
            app/src/main/java/com/bedrock/padder/activity/MainActivity.java on lines 620..620

            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