Showing 108 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();
- Read upRead up
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");
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);
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 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) {
- Read upRead up
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 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) {
- Read upRead up
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
section.add(Hood.get().createPropertyEntry("don't keep activities", new DynamicValue<String>() {
@Override
public String getValue() {
int settingsInt;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) {
- Read upRead up
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 113.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
section.add(Hood.get().createPropertyEntry("usb-debugging", new DynamicValue<String>() {
@Override
public String getValue() {
int settingsInt;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) {
- Read upRead up
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 113.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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>() {
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;
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76