patrickfav/under-the-hood

View on GitHub

Showing 71 of 108 total issues

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

    Method setContent has a Cognitive Complexity of 6 (exceeds 5 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);
    
    

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

            public int getPosForItem(SpinnerElement element) {
                if (element != null) {
                    for (int i = 0; i < getCount(); i++) {
                        if (element.equals(getItem(i))) {
                            return i;

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

        @Override
        public void add(@Nullable PageEntry<?> pageEntry) {
            if (pageEntry != null) {
                entries.add(pageEntry);
                ViewTemplate<?> template = pageEntry.createViewTemplate();
    Severity: Minor
    Found in hood-core/src/release/java/at/favre/lib/hood/internal/DebugPage.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 getValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

                @Override
                public SpinnerElement getValue() {
                    String currentId = prefs.getString(backendIdPrefKey, defaultId);
                    if (currentId != null) {
                        for (SpinnerElement element : elements) {

    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 createPmActivitiesInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). 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) {
    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

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

        @Override
        public Parcelable saveState() {
            Bundle state = new Bundle();
            if (viewPager != null) {
                for (int i = 0; i < viewPager.getChildCount(); i++) {
    Severity: Minor
    Found in hood-core/src/main/java/at/favre/lib/hood/view/DebugViewPageAdapter.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 createPmBroadcastReceiversInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). 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) {
    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 createPmServiceInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static List<PageEntry<?>> createPmServiceInfo(@NonNull PackageInfo packageInfo) {
            List<PageEntry<?>> entries = new ArrayList<>();
            if (packageInfo.services != null) {
                for (ServiceInfo service : packageInfo.services) {
                    if (service != 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 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

    Severity
    Category
    Status
    Source
    Language