appframework/src/main/java/com/alibaba/weex/commons/AbsWeexActivity.java
AbsWeexActivity
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
Open
public abstract class AbsWeexActivity extends AppCompatActivity implements IWXRenderListener {
private static final String TAG = "AbsWeexActivity";
protected BroadcastReceiver mBroadcastReceiver;
protected ViewGroup mContainer;
protected WXSDKInstance mInstance;
Method registerBroadcastReceiver
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void registerBroadcastReceiver(BroadcastReceiver receiver, IntentFilter filter) {
mBroadcastReceiver = receiver != null ? receiver : new DefaultBroadcastReceiver();
if (filter == null) {
filter = new IntentFilter();
}
Method runWithPermissionsCheck
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
public void runWithPermissionsCheck(int requestCode, String permission, Runnable runnable) {
if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, permission)) {
Toast.makeText(this, "please give me the permission", Toast.LENGTH_SHORT).show();
} else {
- 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 onReceive
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
@Override
public void onReceive(Context context, Intent intent) {
if (IWXDebugProxy.ACTION_DEBUG_INSTANCE_REFRESH.equals(intent.getAction())) {
if (mRefreshListener != null) {
mRefreshListener.onRefresh();
- 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"