MarshallAsch/solitaire

View on GitHub

Showing 119 of 119 total issues

Consider simplifying this complex logical expression.
Open

                    else if (movePile.isEmpty() && pile.get(i).size() > 0 && i > 7 && e.getY() >= 5 &&
                             e.getY() <= 96 && e.getX() >= 404 + 68*(i-8) && e.getX() <= 404 + 68*(i-7) &&
                             moved.getNum() == pile.get(i).get(pile.get(i).size()-1).getNum() + 1 &&
                             pile.get(i).get(pile.get(i).size()-1).getSuit() == moved.getSuit())
                    {
Severity: Critical
Found in solitare/Board.java - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

                    if(num1+1 == num2 && ((suit1 == 'H' || suit1 == 'D') && (suit2 == 'C' || suit2 == 'S')) 
                            || ((suit2 == 'H' || suit2 == 'D') && (suit1 == 'C' || suit1 == 'S')))
                         counter++; 
Severity: Critical
Found in solitare/Board.java - About 1 hr to fix

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

          else if (amount == 1)
          {
               cardLeft = 1;
          }
          else
Severity: Major
Found in solitare/Board.java and 1 other location - About 1 hr to fix
solitare/Board.java on lines 733..749

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

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

          if (amount > 0)
          {
               cardLeft = 1;
          }
          else
Severity: Major
Found in solitare/Board.java and 1 other location - About 1 hr to fix
solitare/Board.java on lines 692..708

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

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 paint has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     public void paint(Graphics g)
     {
          int up;
          
          //paint the titles
Severity: Minor
Found in solitare/HighScorePanel2.java - About 1 hr to fix

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

     private void initOptions()
     {
          title3 = new JLabel("Options");
          optionPanel = new JPanel(new GridLayout(0, 1));
          
Severity: Major
Found in solitare/NewUserSettingsPanel.java and 1 other location - About 1 hr to fix
solitare/SettingsPanel.java on lines 496..512

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

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

     private void initOptions()
     {
          title3 = new JLabel("Options");
          optionPanel = new JPanel(new GridLayout(0, 1));
          
Severity: Major
Found in solitare/SettingsPanel.java and 1 other location - About 1 hr to fix
solitare/NewUserSettingsPanel.java on lines 307..325

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

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 mergeParts has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     private  void mergeParts(int lower, int middle, int higher)
     {
          for (int i = lower; i <= higher; i++) {
               for (int j = 0; j < 5; j++)
               {
Severity: Minor
Found in solitare/Sort.java - About 1 hr to fix

Method createNewUser has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     private void createNewUser()
     {
          try
          {
               File inputFile = new File("UserSetings.dtd");  //open file to get all old users
Severity: Minor
Found in solitare/Login.java - About 1 hr to fix

Method mouseClicked has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     public void mouseClicked (MouseEvent e)
     {
          //if game is stoped do nothing
          if (!play)
               return;
Severity: Minor
Found in solitare/Board.java - About 1 hr to fix

Method initColorSelection has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     private void initColorSelection()
     {
          labels = new JPanel(new GridLayout(0, 1));
          boxes = new JPanel(new GridLayout(0, 1));
          sliders = new JPanel(new GridLayout(0, 1));
Severity: Minor
Found in solitare/NewUserSettingsPanel.java - About 1 hr to fix

Method flip3 has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     private void flip3()
     {
          int cardLeft = 0, amount = temp.size() - 1;
          
          //pre pair to flip the correct number of cards if there are not enough left to flip 3
Severity: Minor
Found in solitare/Board.java - About 1 hr to fix

Method initColorSelection has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     private void initColorSelection()
     {
          labels = new JPanel(new GridLayout(0, 1));
          boxes = new JPanel(new GridLayout(0, 1));
          sliders = new JPanel(new GridLayout(0, 1));
Severity: Minor
Found in solitare/SettingsPanel.java - About 1 hr to fix

Method paint has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

     public void paint(Graphics g)
     {
          int up;
          
          //paint the titles
Severity: Minor
Found in solitare/HighScorePanel2.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 settings has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

     public void settings(int loginStatus)
     {
          //if no user is logged in then set to 0 (default user)
          if (loginStatus == -1)
               loginStatus = 0;
Severity: Minor
Found in solitare/Board.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 initCardBack has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     private void initCardBack()
     {
          buttonGroup1 = new ButtonGroup();
          
          title1 = new JLabel("Choose a card back");
Severity: Minor
Found in solitare/SettingsPanel.java - About 1 hr to fix

Method settings has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     public void settings(int loginStatus)
     {
          //if no user is logged in then set to 0 (default user)
          if (loginStatus == -1)
               loginStatus = 0;
Severity: Minor
Found in solitare/Board.java - About 1 hr to fix

Method initCardBack has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

     private void initCardBack()
     {
          buttonGroup1 = new ButtonGroup();
          
          title1 = new JLabel("Choose a card back");
Severity: Minor
Found in solitare/NewUserSettingsPanel.java - About 1 hr to fix

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

               try {
                    Transformer tr = TransformerFactory.newInstance().newTransformer();
                    tr.setOutputProperty(OutputKeys.INDENT, "yes");
                    tr.setOutputProperty(OutputKeys.METHOD, "xml");
                    tr.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
Severity: Major
Found in solitare/Login.java and 2 other locations - About 1 hr to fix
solitare/Login.java on lines 176..190
solitare/SettingsPanel.java on lines 365..378

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

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 3 locations. Consider refactoring.
Open

               try {
                    Transformer tr = TransformerFactory.newInstance().newTransformer();
                    tr.setOutputProperty(OutputKeys.INDENT, "yes");
                    tr.setOutputProperty(OutputKeys.METHOD, "xml");
                    tr.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
Severity: Major
Found in solitare/Login.java and 2 other locations - About 1 hr to fix
solitare/Login.java on lines 316..329
solitare/SettingsPanel.java on lines 365..378

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

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

Severity
Category
Status
Source
Language