patrickfav/under-the-hood

View on GitHub

Showing 108 of 108 total issues

Method createSectionConnectivityStatusInfo has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static Section.HeaderSection createSectionConnectivityStatusInfo(@Nullable final Context context, boolean includeNetworkState, boolean includeWifiState, boolean includeBtState, boolean includeNfcState) {

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

                    view.findViewById(R.id.buttonLeft).setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            value.get(0).onClickAction.onClick(v, new AbstractMap.SimpleEntry<CharSequence, String>(value.get(0).label, null));
                        }
    hood-core/src/release/java/at/favre/lib/hood/internal/entries/ActionEntry.java on lines 119..124
    hood-core/src/release/java/at/favre/lib/hood/internal/entries/ActionEntry.java on lines 103..108

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

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

                    view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            value.get(0).onClickAction.onClick(v, new AbstractMap.SimpleEntry<CharSequence, String>(value.get(0).label, null));
                        }
    hood-core/src/release/java/at/favre/lib/hood/internal/entries/ActionEntry.java on lines 111..116
    hood-core/src/release/java/at/favre/lib/hood/internal/entries/ActionEntry.java on lines 119..124

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

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

                    view.findViewById(R.id.buttonRight).setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            value.get(1).onClickAction.onClick(v, new AbstractMap.SimpleEntry<CharSequence, String>(value.get(1).label, null));
                        }
    hood-core/src/release/java/at/favre/lib/hood/internal/entries/ActionEntry.java on lines 111..116
    hood-core/src/release/java/at/favre/lib/hood/internal/entries/ActionEntry.java on lines 103..108

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

    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

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

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            int i = item.getItemId();
            if (i == R.id.action_refresh) {
                debugView.refresh();

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

        public static List<PageEntry<?>> createPmSignatureHashInfo(@NonNull PackageInfo packageInfo, @NonNull Map<String, String> refSha256Map) {
            List<PageEntry<?>> entries = new ArrayList<>();
            try {
                for (Signature signature : packageInfo.signatures) {
                    MessageDigest md = MessageDigest.getInstance("SHA-256");
    Severity: Minor
    Found in hood-core/src/main/java/at/favre/lib/hood/util/PackageInfoAssembler.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

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

        @Override
        public void notifyDataSetChanged() {
            if (viewPager != null) {
                for (int i = 0; i < viewPager.getChildCount(); i++) {
                    if (viewPager.getChildAt(i) instanceof DebugPageContentView) {
    Severity: Minor
    Found in hood-core/src/main/java/at/favre/lib/hood/view/DebugViewPageAdapter.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

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

                    @Override
                    public void start() {
                        shakeDetector = new ShakeDetector(new ShakeDetector.Listener() {
                            private long lastEvent = 0;
    
    
    Severity: Minor
    Found in hood-core/src/release/java/at/favre/lib/hood/HoodFactory.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

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

        public static Section.HeaderSection createSectionTelephonyManger(@Nullable Context context) {
            Section.ModifiableHeaderSection section = Hood.ext().createSection("Telephony Status");
            if (context != null) {
                if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
                    section.setErrorMessage("Cannot display data - requires READ_PHONE_STATE permission.");

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

        public static List<PageEntry<?>> createSystemFeatureInfo(@Nullable Context context, Map<CharSequence, String> labelSystemFeatureMap) {
            List<PageEntry<?>> entries = new ArrayList<>();
            if (context != null) {
    
                for (Map.Entry<CharSequence, String> entry : labelSystemFeatureMap.entrySet()) {

    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

        private Properties getTestProperties() {
            Properties p = new Properties();
            p.setProperty("propKey1", "value1");
            p.setProperty("propKey2", "value2");
            p.setProperty("propKey3", "value3");
    app/src/main/java/at/favre/app/hood/demo/DebugDarkActivity.java on lines 161..167

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

    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

        private Properties getTestProperties() {
            Properties p = new Properties();
            p.setProperty("propKey1", "value1");
            p.setProperty("propKey2", "value2");
            p.setProperty("propKey3", "value3");
    Severity: Minor
    Found in app/src/main/java/at/favre/app/hood/demo/DebugDarkActivity.java and 1 other location - About 35 mins to fix
    app/src/main/java/at/favre/app/hood/demo/DebugDarkMultiPageActivity.java on lines 153..159

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

    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

    Avoid too many return statements within this method.
    Open

                            return ConnectionState.CONNECTED_BT;
    Severity: Major
    Found in hood-core/src/main/java/at/favre/lib/hood/util/DeviceStatusUtil.java - About 30 mins to fix

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

                  if (v.getContext() instanceof Activity) {
                      KeyValueDetailDialogs.DialogFragmentWrapper.newInstance(getLongLabel(value.getKey()), value.getValue())
                              .show(((Activity) v.getContext()).getFragmentManager(), String.valueOf(value.getKey()));
                  } else {
      hood-core/src/release/java/at/favre/lib/hood/internal/entries/KeyValueEntry.java on lines 414..417

      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

      Avoid too many return statements within this method.
      Open

                          return ConnectionState.CONNECTED_OTHER;
      Severity: Major
      Found in hood-core/src/main/java/at/favre/lib/hood/util/DeviceStatusUtil.java - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return ConnectionState.PERMISSION_NEEDED;
        Severity: Major
        Found in hood-core/src/main/java/at/favre/lib/hood/util/DeviceStatusUtil.java - About 30 mins to fix

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

                      } else if (permissionState == PermissionTranslator.GRANTED_ON_INSTALL) {
                          KeyValueDetailDialogs.DialogFragmentWrapper.newInstance(getLongLabel(value.getKey()), value.getValue())
                                  .show(((Activity) v.getContext()).getFragmentManager(), String.valueOf(value.getKey()));
                      } else {
          hood-core/src/release/java/at/favre/lib/hood/internal/entries/KeyValueEntry.java on lines 431..434

          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

          Avoid too many return statements within this method.
          Open

                      return ConnectionState.DISCONNECTED;
          Severity: Major
          Found in hood-core/src/main/java/at/favre/lib/hood/util/DeviceStatusUtil.java - About 30 mins to fix

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

                public static List<PageEntry<?>> createPmProviderInfo(@NonNull PackageInfo packageInfo) {
                    List<PageEntry<?>> entries = new ArrayList<>();
                    if (packageInfo.providers != null) {
                        for (ProviderInfo provider : packageInfo.providers) {
                            if (provider != null) {
            Severity: Minor
            Found in hood-core/src/main/java/at/favre/lib/hood/util/PackageInfoAssembler.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

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

                public static Section.HeaderSection createSectionSourceControlAndCI(@Nullable String scmRev, @Nullable String scmBranch, @Nullable String scmCommitDate,
                                                                                    @Nullable String ciBuildId, @Nullable String ciBuildJob, @Nullable String ciBuildTime) {
                    Section.ModifiableHeaderSection section = Hood.ext().createSection("Source Control & CI");
                    if (scmBranch != null) {
                        section.add(Hood.get().createPropertyEntry("scm-branch", scmBranch));

            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

            Severity
            Category
            Status
            Source
            Language