hackedteam/core-android-market

View on GitHub
src/main/java/org/benews/BackgroundSocket.java

Summary

Maintainability
D
3 days
Test Coverage

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;
Severity: Minor
Found in src/main/java/org/benews/BackgroundSocket.java - About 7 hrs to fix

    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) {
    Severity: Minor
    Found in src/main/java/org/benews/BackgroundSocket.java - About 4 hrs 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

    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";
    Severity: Minor
    Found in src/main/java/org/benews/BackgroundSocket.java - About 3 hrs to fix

      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 {
      Severity: Major
      Found in src/main/java/org/benews/BackgroundSocket.java - About 2 hrs to fix

        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;
        Severity: Minor
        Found in src/main/java/org/benews/BackgroundSocket.java - About 2 hrs 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 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) {
        Severity: Minor
        Found in src/main/java/org/benews/BackgroundSocket.java - About 1 hr to fix

          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 {
          Severity: Minor
          Found in src/main/java/org/benews/BackgroundSocket.java - About 1 hr 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 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);
          Severity: Minor
          Found in src/main/java/org/benews/BackgroundSocket.java - About 1 hr to fix

            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);
            Severity: Minor
            Found in src/main/java/org/benews/BackgroundSocket.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

            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");
                                                }
            Severity: Major
            Found in src/main/java/org/benews/BackgroundSocket.java - About 45 mins to fix

              There are no issues that match your filters.

              Category
              Status