patrickfav/under-the-hood

View on GitHub

Showing 71 of 108 total issues

Method equals has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

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

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

    public static SingleSelectListConfigAction getDefaultSharedPrefBackedSpinnerAction(@Nullable String label, @NonNull final SharedPreferences prefs, final @NonNull String backendIdPrefKey, final @Nullable String defaultId, @NonNull final List<SpinnerElement> elements) {
        return new SingleSelectListConfigAction(label, new SpinnerValue<List<SpinnerElement>, SpinnerElement>() {

            @SuppressLint("CommitPrefEdits")
            @Override

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 createSectionConnectivityStatusInfo has a Cognitive Complexity of 9 (exceeds 5 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) {

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

    @SuppressLint("NewApi")
    public static List<PageEntry<?>> createPmPermissionInfo(final @NonNull Context context, @NonNull PackageInfo packageInfo, boolean onlyDangerousPermissions) {

        if (!(context instanceof Activity)) {
            throw new IllegalArgumentException("context must be of type activity - needed for getting current permission state");
Severity: Minor
Found in hood-core/src/main/java/at/favre/lib/hood/util/PackageInfoAssembler.java - About 55 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 addAction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public static void addAction(@NonNull Page page, @Nullable ButtonDefinition action1, @Nullable ButtonDefinition action2) {
        if (action1 == null && action2 != null) {
            addAction(page, action2);
        } else if (action1 != null && action2 == null) {
            addAction(page, action1);
Severity: Minor
Found in hood-core/src/main/java/at/favre/lib/hood/util/PageUtil.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 createSectionSourceControlAndCI has 6 arguments (exceeds 4 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) {

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

        public static SingleSelectListConfigAction getDefaultSharedPrefBackedSpinnerAction(@Nullable String label, @NonNull final SharedPreferences prefs, final @NonNull String backendIdPrefKey, final @Nullable String defaultId, @NonNull final List<SpinnerElement> elements) {

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

              private View getFromResources(int position, @Nullable View convertView,
                                            @NonNull ViewGroup parent, @LayoutRes int layout, String tag) {

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

            public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed,
                                                int dyUnconsumed, int[] offsetInWindow) {
        Severity: Minor
        Found in hood-core/src/main/java/at/favre/lib/hood/view/DebugPageContentView.java - About 35 mins to fix

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

              private static List<PageEntry<?>> createTxRxdSection(String name, final long txBytes,
                                                                   final long txPackets, final long rxBytes, final long rxPackets) {

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

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

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

              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

                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

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