mrksbrg/RacketGhost

View on GitHub

Showing 42 of 42 total issues

Method onProgressUpdate has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

        @Override
        protected void onProgressUpdate(String... progress) {
            if (progress == null) {
                Toast toast = Toast.makeText(getApplicationContext(), "Set completed!", Toast.LENGTH_SHORT);
                toast.show();
Severity: Minor
Found in app/src/main/java/com/markusborg/ui/GhostingActivity.java - About 5 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

File GhostingActivity.java has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package com.markusborg.ui;

import android.annotation.TargetApi;
import android.content.Intent;
import android.graphics.drawable.Drawable;
Severity: Minor
Found in app/src/main/java/com/markusborg/ui/GhostingActivity.java - About 4 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public CourtPosition serve()
        {
            CourtPosition servePos = null;
            if (sixPoint) {
                switch (rand.nextInt(6)) {
    Severity: Major
    Found in app/src/main/java/com/markusborg/logic/GhostPlayer.java and 1 other location - About 3 hrs to fix
    app/src/main/java/com/markusborg/logic/GhostPlayer.java on lines 82..125

    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 227.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public CourtPosition nextStrike()
        {
            CourtPosition strikePos = null;
            if (sixPoint) {
                switch (rand.nextInt(6)) {
    Severity: Major
    Found in app/src/main/java/com/markusborg/logic/GhostPlayer.java and 1 other location - About 3 hrs to fix
    app/src/main/java/com/markusborg/logic/GhostPlayer.java on lines 29..72

    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 227.

    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

    Further Reading

    Method doInBackground has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

            @Override
            protected String doInBackground(Setting... params) {
                Setting theSetting = params[0];
                GhostPlayer theGhost = new GhostPlayer(theSetting.isSixPoints());
    
    
    Severity: Minor
    Found in app/src/main/java/com/markusborg/ui/GhostingActivity.java - About 3 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 onProgressUpdate has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            @Override
            protected void onProgressUpdate(String... progress) {
                if (progress == null) {
                    Toast toast = Toast.makeText(getApplicationContext(), "Set completed!", Toast.LENGTH_SHORT);
                    toast.show();
    Severity: Major
    Found in app/src/main/java/com/markusborg/ui/GhostingActivity.java - About 2 hrs to fix

      Method onCreate has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_ghosting);
              Bundle extras = getIntent().getExtras();
      Severity: Major
      Found in app/src/main/java/com/markusborg/ui/GhostingActivity.java - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                if (!Character.isDigit(date.charAt(0)) ||
                        !Character.isDigit(date.charAt(1)) ||
                        !Character.isDigit(date.charAt(2)) ||
                        !Character.isDigit(date.charAt(3)) ||
                        date.charAt(4) != '-' ||
        Severity: Critical
        Found in app/src/main/java/com/markusborg/logic/Setting.java - About 2 hrs to fix

          Method onCreate has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Override
              protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_main);
          
          
          Severity: Minor
          Found in app/src/main/java/com/markusborg/ui/MainActivity.java - About 1 hr to fix

            Method doInBackground has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    @Override
                    protected String doInBackground(Setting... params) {
                        Setting theSetting = params[0];
                        GhostPlayer theGhost = new GhostPlayer(theSetting.isSixPoints());
            
            
            Severity: Minor
            Found in app/src/main/java/com/markusborg/ui/GhostingActivity.java - About 1 hr to fix

              Method serve has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public CourtPosition serve()
                  {
                      CourtPosition servePos = null;
                      if (sixPoint) {
                          switch (rand.nextInt(6)) {
              Severity: Minor
              Found in app/src/main/java/com/markusborg/logic/GhostPlayer.java - About 1 hr to fix

                Method nextStrike has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public CourtPosition nextStrike()
                    {
                        CourtPosition strikePos = null;
                        if (sixPoint) {
                            switch (rand.nextInt(6)) {
                Severity: Minor
                Found in app/src/main/java/com/markusborg/logic/GhostPlayer.java - About 1 hr to fix

                  Method setSettingFromString has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private boolean setSettingFromString(String input) {
                          // Example of valid string
                          // 2015-11-24 (SQ): 1; 1; 1; 1
                  
                          // shortest possible string is 27 characters
                  Severity: Minor
                  Found in app/src/main/java/com/markusborg/logic/Setting.java - About 1 hr to fix

                    Method getView has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public View getView(int position, View convertView, ViewGroup parent){
                            View v = convertView;
                    
                            if (v == null) {
                                LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    Severity: Minor
                    Found in app/src/main/java/com/markusborg/ui/SessionAdapter.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 setSettingFromString has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private boolean setSettingFromString(String input) {
                            // Example of valid string
                            // 2015-11-24 (SQ): 1; 1; 1; 1
                    
                            // shortest possible string is 27 characters
                    Severity: Minor
                    Found in app/src/main/java/com/markusborg/logic/Setting.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 displayCountdown has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            private void displayCountdown() {
                                publishProgress("5");
                                try {
                                    Thread.sleep(1000);
                                } catch (InterruptedException e) {
                    Severity: Minor
                    Found in app/src/main/java/com/markusborg/ui/GhostingActivity.java - About 1 hr to fix

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                              try {
                                  //Inflate the custom view
                                  LayoutInflater inflater = callingActivity.getLayoutInflater();
                                  about = inflater.inflate(R.layout.about_box, (ViewGroup) callingActivity.findViewById(R.id.aboutView));
                                  tvAbout = (TextView) about.findViewById(R.id.aboutText);
                      Severity: Major
                      Found in app/src/main/java/com/markusborg/ui/HelpBox.java and 1 other location - About 1 hr to fix
                      app/src/main/java/com/markusborg/ui/AboutBox.java on lines 33..41

                      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 78.

                      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

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                              try {
                                  //Inflate the custom view
                                  LayoutInflater inflater = callingActivity.getLayoutInflater();
                                  about = inflater.inflate(R.layout.about_box, (ViewGroup) callingActivity.findViewById(R.id.aboutView));
                                  tvAbout = (TextView) about.findViewById(R.id.aboutText);
                      Severity: Major
                      Found in app/src/main/java/com/markusborg/ui/AboutBox.java and 1 other location - About 1 hr to fix
                      app/src/main/java/com/markusborg/ui/HelpBox.java on lines 32..40

                      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 78.

                      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

                      Further Reading

                      Method getView has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public View getView(int position, View convertView, ViewGroup parent){
                              View v = convertView;
                      
                              if (v == null) {
                                  LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                      Severity: Minor
                      Found in app/src/main/java/com/markusborg/ui/SessionAdapter.java - About 1 hr to fix

                        Method addSessionToLog has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public void addSessionToLog(Setting theSetting) {
                                // move all history items one position
                                if (n == 1) {
                                    history[1] = history[0];
                                }
                        Severity: Minor
                        Found in app/src/main/java/com/markusborg/logic/LogHandler.java - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language