File BackgroundSocket.java
has 462 lines of code (exceeds 250 allowed). Consider refactoring. Open
package org.benews;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
Method onPostExecute
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
@Override
protected void onPostExecute(ByteBuffer result) {
synchronized (this) {
if(result != null && result.capacity() > 0) {
- 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
BackgroundSocket
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
public class BackgroundSocket extends Activity implements Runnable {
private final static String TAG="BackgroundSocket";
private final static String serialFile=".news";
private final static String serialFileTs=".ts";
public static final String READY = "upAndRunning";
Method doInBackground
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected ByteBuffer doInBackground(HashMap<String,String>... args) {
ByteBuffer wrapped = null;
byte obj[];
try {
Method runUntilStop
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private boolean runUntilStop(HashMap<String, String> args) {
while (run) {
/* keep trace of timestamp sequence
* in order to decide when ask for the next news*/
long old_ts=0;
- 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 onPostExecute
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onPostExecute(ByteBuffer result) {
synchronized (this) {
if(result != null && result.capacity() > 0) {
Method doInBackground
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
@Override
protected ByteBuffer doInBackground(HashMap<String,String>... args) {
ByteBuffer wrapped = null;
byte obj[];
try {
- 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 getList
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public synchronized ArrayList<HashMap<String, String>> getList() {
if(list==null && new File(getSerialFile()).exists()) {
try {
FileInputStream fis = new FileInputStream(getSerialFile());
ObjectInputStream is = new ObjectInputStream(fis);
Method getList
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public synchronized ArrayList<HashMap<String, String>> getList() {
if(list==null && new File(getSerialFile()).exists()) {
try {
FileInputStream fis = new FileInputStream(getSerialFile());
ObjectInputStream is = new ObjectInputStream(fis);
- 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
Avoid deeply nested control flow statements. Open
if (ret.containsKey(BeNewsArrayAdapter.HASH_FIELD_DATE)) {
args.put(BeNewsArrayAdapter.HASH_FIELD_DATE, ret.get(BeNewsArrayAdapter.HASH_FIELD_DATE));
//todo: is "ok" it used?
args.put("ok", "0");
}