patrickfav/under-the-hood

View on GitHub

Showing 108 of 108 total issues

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

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

hood-core/src/release/java/at/favre/lib/hood/internal/DebugPage.java on lines 170..181
hood-core/src/release/java/at/favre/lib/hood/internal/DebugPages.java on lines 123..133
hood-core/src/release/java/at/favre/lib/hood/internal/UnmodifiablePages.java on lines 90..101

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

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

    public static Section.HeaderSection createInternalProcessDebugInfo(@Nullable final Context context) {
        Section.ModifiableHeaderSection section = Hood.ext().createSection("Process Debug Info");

        if (context != null) {
            section.add(Hood.get().createPropertyEntry("heap-native", new DynamicValue<String>() {

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

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
    
    
    hood-core/src/main/java/at/favre/lib/hood/interfaces/values/SpinnerElement.java on lines 55..65
    hood-core/src/release/java/at/favre/lib/hood/internal/DebugPages.java on lines 123..133
    hood-core/src/release/java/at/favre/lib/hood/internal/UnmodifiablePages.java on lines 90..101

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

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

        public Section createSection(@Nullable Context context, boolean addSectionHeaders) {
            Section.ModifiableHeaderSection mainSection = Hood.ext().createSection("");
            if (context != null) {
                String targetPackageName = packageName == null ? context.getPackageName() : packageName;
                try {

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

        public static Section.HeaderSection createSectionAppVersionInfoFromBuildConfig(Class<?> buildConfig) {
            Section.ModifiableHeaderSection section = Hood.ext().createSection("App Version");
            Field[] declaredFields = buildConfig.getDeclaredFields();
            for (Field field : declaredFields) {
                if (Modifier.isStatic(field.getModifiers())) {

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

        @NonNull
        @Override
        public Pages getPageData(@NonNull Pages pages) {
            Page firstPage = pages.addNewPage();
    
    
    Severity: Minor
    Found in app/src/main/java/at/favre/app/hood/demo/DebugLightActivity.java - About 1 hr to fix

      Method onTouch has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public boolean onTouch(View v, MotionEvent event) {
              if (onClickListener == null) {
                  return false;
              }

        Method createPages has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public Pages createPages() {
                Pages pages = Hood.get().createPages(Config.newBuilder().setShowHighlightContent(false).build());
                Page firstPage = pages.addNewPage("Debug Info");
                firstPage.add(DefaultProperties.createSectionAppVersionInfoFromBuildConfig(at.favre.lib.hood.BuildConfig.class));
                firstPage.add(DefaultProperties.createSectionBasicDeviceInfo());
        Severity: Minor
        Found in app/src/main/java/at/favre/app/hood/demo/DebugDrawerActivity.java - About 1 hr to fix

          Method setContent has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  @Override
                  public void setContent(final Map.Entry<CharSequence, KeyValueEntry.Value<String>> entry, @NonNull final View view) {
                      ((TextView) view.findViewById(R.id.key)).setText(entry.getKey());
                      TextView tvValue = view.findViewById(R.id.value);
          
          

            Method createSectionAppVersionInfoFromBuildConfig has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static Section.HeaderSection createSectionAppVersionInfoFromBuildConfig(Class<?> buildConfig) {
                    Section.ModifiableHeaderSection section = Hood.ext().createSection("App Version");
                    Field[] declaredFields = buildConfig.getDeclaredFields();
                    for (Field field : declaredFields) {
                        if (Modifier.isStatic(field.getModifiers())) {

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

                      @Override
                      public ManagerControl registerShakeToOpenDebugActivity(final Context ctx, final Intent intent) {
                          final SensorManager sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
                          return new ManagerControl() {
                              private boolean isSupported = true;
              Severity: Minor
              Found in hood-core/src/release/java/at/favre/lib/hood/HoodFactory.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

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

                  public static List<PageEntry<?>> createPmActivitiesInfo(@NonNull PackageInfo packageInfo) {
                      List<PageEntry<?>> entries = new ArrayList<>();
                      if (packageInfo.activities != null) {
                          for (ActivityInfo receiver : packageInfo.activities) {
                              if (receiver != null) {
              hood-core/src/main/java/at/favre/lib/hood/util/PackageInfoAssembler.java on lines 303..315

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

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

                  public static List<PageEntry<?>> createPmBroadcastReceiversInfo(@NonNull PackageInfo packageInfo) {
                      List<PageEntry<?>> entries = new ArrayList<>();
                      if (packageInfo.receivers != null) {
                          for (ActivityInfo receiver : packageInfo.receivers) {
                              if (receiver != null) {
              hood-core/src/main/java/at/favre/lib/hood/util/PackageInfoAssembler.java on lines 347..359

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

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

                      @Override
                      public ManagerControl registerShakeToOpenDebugActivity(final Context ctx, final Intent intent) {
                          final SensorManager sensorManager = (SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE);
                          return new ManagerControl() {
                              private boolean isSupported = true;
              Severity: Minor
              Found in hood-core/src/release/java/at/favre/lib/hood/HoodFactory.java - About 1 hr to fix

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

                    private List<SpinnerElement> getBackendElements() {
                        List<SpinnerElement> elements = new ArrayList<>();
                        elements.add(new Backend(1, "dev.backend.com", 443));
                        elements.add(new Backend(2, "dev2.backend.com", 80));
                        elements.add(new Backend(3, "dev3.backend.com", 80));
                app/src/main/java/at/favre/app/hood/demo/DebugDarkActivity.java on lines 169..177
                app/src/main/java/at/favre/app/hood/demo/DebugDarkMultiPageActivity.java on lines 161..169
                app/src/main/java/at/favre/app/hood/demo/DebugPerformanceTestActivity.java on lines 83..91

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

                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

                    private List<SpinnerElement> getBackendElements() {
                        List<SpinnerElement> elements = new ArrayList<>();
                        elements.add(new Backend(1, "dev.backend.com", 443));
                        elements.add(new Backend(2, "dev2.backend.com", 80));
                        elements.add(new Backend(3, "dev3.backend.com", 80));
                app/src/main/java/at/favre/app/hood/demo/DebugDarkActivity.java on lines 169..177
                app/src/main/java/at/favre/app/hood/demo/DebugDarkMultiPageActivity.java on lines 161..169
                app/src/main/java/at/favre/app/hood/demo/DebugDrawerActivity.java on lines 133..141

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

                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

                    private List<SpinnerElement> getBackendElements() {
                        List<SpinnerElement> elements = new ArrayList<>();
                        elements.add(new Backend(1, "dev.backend.com", 443));
                        elements.add(new Backend(2, "dev2.backend.com", 80));
                        elements.add(new Backend(3, "dev3.backend.com", 80));
                app/src/main/java/at/favre/app/hood/demo/DebugDarkActivity.java on lines 169..177
                app/src/main/java/at/favre/app/hood/demo/DebugDrawerActivity.java on lines 133..141
                app/src/main/java/at/favre/app/hood/demo/DebugPerformanceTestActivity.java on lines 83..91

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

                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

                    private List<SpinnerElement> getBackendElements() {
                        List<SpinnerElement> elements = new ArrayList<>();
                        elements.add(new Backend(1, "dev.backend.com", 443));
                        elements.add(new Backend(2, "dev2.backend.com", 80));
                        elements.add(new Backend(3, "dev3.backend.com", 80));
                app/src/main/java/at/favre/app/hood/demo/DebugDarkMultiPageActivity.java on lines 161..169
                app/src/main/java/at/favre/app/hood/demo/DebugDrawerActivity.java on lines 133..141
                app/src/main/java/at/favre/app/hood/demo/DebugPerformanceTestActivity.java on lines 83..91

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

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

                    @NonNull
                    @Override
                    public Pages getPageData(@NonNull Pages pages) {
                        final Random random = new Random();
                
                

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

                    @Override
                    protected void onCreate(@Nullable Bundle savedInstanceState) {
                        super.onCreate(savedInstanceState);
                        if (Hood.isLibEnabled()) {
                            if (getIntent().getBooleanExtra(KEY_HEADLESS, false)) {
                  Severity
                  Category
                  Status
                  Source
                  Language