batebates/sudoku

View on GitHub
src/controller/SudokuAPI.rb

Summary

Maintainability
D
1 day
Test Coverage

Class SudokuAPI has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

class SudokuAPI
    include Observable
#== Variables d'instances ==
    @sudoku
    @sudokuCompleted
Severity: Minor
Found in src/controller/SudokuAPI.rb - About 4 hrs to fix

File SudokuAPI.rb has 296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class SudokuAPI
    include Observable
#== Variables d'instances ==
    @sudoku
    @sudokuCompleted
Severity: Minor
Found in src/controller/SudokuAPI.rb - About 3 hrs to fix

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

    def loadSudoku(fileName)
        filePath = "save_files/#{fileName}"
        if(File.file?(filePath))
            loadFile = File.new(filePath, "r")

Severity: Minor
Found in src/controller/SudokuAPI.rb - 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 saveSudoku has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def saveSudoku(fileName)
        saveFile = File.new("save_files/"+fileName, "w")

        if(!saveFile.closed?)
            print "Fichier de sauvegarde ouvert\n"
Severity: Minor
Found in src/controller/SudokuAPI.rb - About 1 hr to fix

Method loadSudoku has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def loadSudoku(fileName)
        filePath = "save_files/#{fileName}"
        if(File.file?(filePath))
            loadFile = File.new(filePath, "r")

Severity: Minor
Found in src/controller/SudokuAPI.rb - About 1 hr to fix

Method saveSudoku has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def saveSudoku(fileName)
        saveFile = File.new("save_files/"+fileName, "w")

        if(!saveFile.closed?)
            print "Fichier de sauvegarde ouvert\n"
Severity: Minor
Found in src/controller/SudokuAPI.rb - 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 showNumber has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def showNumber(number)
        for x in 0...9
            for y in 0...9
                candidats = candidateCaze(x,y);
                if(candidats.include?(number) && !cazeAt(x, y).locked)
Severity: Minor
Found in src/controller/SudokuAPI.rb - About 35 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

Method lockSudoku has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def lockSudoku()
        for i in 0...9
            for j in 0...9
                if(@sudokuStart.hasValue?(i,j))
                    @sudoku.cazeAt(i,j).locked=true
Severity: Minor
Found in src/controller/SudokuAPI.rb - About 25 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

There are no issues that match your filters.

Category
Status