patrickfav/under-the-hood

View on GitHub

Showing 71 of 108 total issues

File DefaultProperties.java has 505 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 *  Copyright 2016 Patrick Favre-Bulle
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.

    DefaultProperties has 52 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public final class DefaultProperties {
    
        private static final String TAG = DefaultProperties.class.getName();
    
        private DefaultProperties() {

      Method getNetworkConnectivityState has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          public static ConnectionState getNetworkConnectivityState(@NonNull Context context) {
              if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_NETWORK_STATE) == PackageManager.PERMISSION_GRANTED) {
                  ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
                  NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
      
      
      Severity: Minor
      Found in hood-core/src/main/java/at/favre/lib/hood/util/DeviceStatusUtil.java - About 3 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

      DefaultButtonDefinitions has 31 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public final class DefaultButtonDefinitions {
      
          private DefaultButtonDefinitions() {
          }
      
      

        File KeyValueEntry.java has 323 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        package at.favre.lib.hood.internal.entries;
        
        import android.app.Activity;
        import android.content.Intent;
        import android.os.Handler;

          Method getPageData has 90 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @NonNull
              @Override
              public Pages getPageData(@NonNull Pages pages) {
                  Page firstPage = pages.addNewPage("General");
          
          
          Severity: Major
          Found in app/src/main/java/at/favre/app/hood/demo/DebugDarkActivity.java - About 3 hrs to fix

            File PackageInfoAssembler.java has 296 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*
             *  Copyright 2016 Patrick Favre-Bulle
             *
             *  Licensed under the Apache License, Version 2.0 (the "License");
             *  you may not use this file except in compliance with the License.

              Method getPageData has 76 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @NonNull
                  @Override
                  public Pages getPageData(@NonNull Pages pages) {
                      Page firstPage = pages.addNewPage("General");
              
              

                Method createSectionTelephonyManger has 60 lines of code (exceeds 25 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.");

                  PackageInfoAssembler has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  public class PackageInfoAssembler {
                      private static final String TAG = PackageInfoAssembler.class.getSimpleName();
                  
                      public enum Type {
                          /**

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

                        @Override
                        protected void onCreate(@Nullable Bundle savedInstanceState) {
                            super.onCreate(savedInstanceState);
                            ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
                    
                    
                    Severity: Major
                    Found in app/src/main/java/at/favre/app/hood/demo/MainActivity.java - About 2 hrs to fix

                      Method createSectionBatteryInfo has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static Section.HeaderSection createSectionBatteryInfo(@Nullable final Context context) {
                              Section.ModifiableHeaderSection section = Hood.ext().createSection("Battery Info");
                              if (context != null) {
                                  final IntentFilter battIntentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
                                  final Intent batteryStatus = context.registerReceiver(null, battIntentFilter);

                        Method createSectionConnectivityStatusInfo has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static Section.HeaderSection createSectionConnectivityStatusInfo(@Nullable final Context context, boolean includeNetworkState, boolean includeWifiState, boolean includeBtState, boolean includeNfcState) {
                                Section.ModifiableHeaderSection section = Hood.ext().createSection("Connectivity Status");
                        
                                if (context != null) {
                                    if (includeNetworkState) {

                          Method createDataMap has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                          Open

                              @Override
                              public Map<String, String> createDataMap() {
                                  Map<String, String> map = new LinkedHashMap<>();
                                  for (PageEntry entry : entries) {
                                      if (entry instanceof KeyValueEntry) {

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

                              public static List<PageEntry<?>> createPmDeclaredSystemFeatureInfo(@NonNull Context context, @NonNull PackageInfo packageInfo) {
                                  try {
                                      Map<CharSequence, String> featureMap = new TreeMap<>();
                                      if (packageInfo.reqFeatures != null && packageInfo.reqFeatures.length > 0) {
                                          for (FeatureInfo reqFeature : packageInfo.reqFeatures) {

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

                              public static Section.HeaderSection createSectionAndroidDebugSettings(final Context context) {
                                  Section.ModifiableHeaderSection section = Hood.ext().createSection("Android Debug Settings");
                                  if (context != null) {
                                      section.add(Hood.get().createPropertyEntry("developer-mode", new DynamicValue<String>() {
                                          @Override

                            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>() {

                              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 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 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
                                Severity
                                Category
                                Status
                                Source
                                Language