davaxi/Takuzu

View on GitHub

Showing 31 of 31 total issues

Function nextResolveSteps has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

protected function nextResolveSteps()
{
if ($this->resolved) {
throw new \LogicException('Grid already resolved');
}
Severity: Minor
Found in src/Resolver.php - About 2 hrs to fix

Function checkExistNecessaryValues has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

protected function checkExistNecessaryValues(array &$needValues, array &$undefinedRanges)
{
if ($needValues[Grid::ZERO] < 0 || $needValues[Grid::ONE] < 0) {
throw new InvalidGridException('Grid line not to be resolved.');
}
Severity: Minor
Found in src/ResolverMethod/NecessaryValues.php - About 2 hrs to fix

Function getPositionFromPossibilities has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

protected static function getPositionFromPossibilities(array $possibilities, $minPosition, $maxPosition)
{
$positions = array_fill($minPosition, $maxPosition - $minPosition + 1, null);
foreach ($possibilities as $possibility) {
foreach ($possibility as $positionNo => $value) {
Severity: Minor
Found in src/ResolverMethod/NoPossibleRange.php - About 1 hr to fix

Function setGridFromArray has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

public function setGridFromArray(array $grid)
{
$lineCount = count($grid);
if ($lineCount % 2 !== 0) {
throw new \InvalidArgumentException('The grid should have an even number line.');
Severity: Minor
Found in src/Grid.php - About 1 hr to fix

Method getRangePossibilities has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public static function getRangePossibilities(array $needs, $leftValues = array(), $rightValues = array())
{
$rangeLength = array_sum($needs);
if (!$rangeLength) {
return array();
Severity: Minor
Found in src/ResolverSeriesGenerator.php - About 1 hr to fix

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

protected function nextResolveSteps()
{
if ($this->resolved) {
throw new \LogicException('Grid already resolved');
}
Severity: Minor
Found in src/Resolver.php - About 1 hr to fix

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

protected function foundOnGridLine(array $line)
{
$count = count($line);
$needValues = static::$helpers->getMissingLineValueDistribution($line);
$undefinedRanges = static::$helpers->getUndefinedRangeLine($line);
Severity: Minor
Found in src/ResolverMethod/NecessaryValues.php - About 1 hr to fix

Method foundOnGridLine has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

protected function foundOnGridLine(array $line)
{
$undefinedRanges = static::$helpers->getUndefinedRangeLine($line);
if (count($undefinedRanges) !== 1) {
return false;
Severity: Minor
Found in src/ResolverMethod/NoPossibleRange.php - About 1 hr to fix

Method setGridFromArray has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function setGridFromArray(array $grid)
{
$lineCount = count($grid);
if ($lineCount % 2 !== 0) {
throw new \InvalidArgumentException('The grid should have an even number line.');
Severity: Minor
Found in src/Grid.php - About 1 hr to fix

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

public static function getUndefinedRangeLine(array $line)
{
$valuesPositions = static::getUndefinedLinePositions($line);
 
$ranges = array();
Severity: Minor
Found in src/GridHelpers.php - About 1 hr to fix

Function __construct has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

public function __construct($width = null, $height = null)
{
$this->checker = new GridChecker($this);
$this->helpers = new GridHelpers();
if (!is_null($width) && !is_null($height)) {
Severity: Minor
Found in src/Grid.php - About 55 mins to fix

Function checkLines has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

protected function checkLines(array &$lines)
{
foreach ($lines as $line) {
if (!$this->checkLineValuesDefined($line)) {
return false;
Severity: Minor
Found in src/GridChecker.php - About 45 mins to fix

Function getUndefinedRangeLine has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

public static function getUndefinedRangeLine(array $line)
{
$valuesPositions = static::getUndefinedLinePositions($line);
 
$ranges = array();
Severity: Minor
Found in src/GridHelpers.php - About 45 mins to fix

Function foundOnGridLine has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

protected function foundOnGridLine(array $line)
{
$count = count($line);
$needValues = static::$helpers->getMissingLineValueDistribution($line);
$undefinedRanges = static::$helpers->getUndefinedRangeLine($line);
Severity: Minor
Found in src/ResolverMethod/NecessaryValues.php - About 45 mins to fix

Function getRangePossibilities has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

public static function getRangePossibilities(array $needs, $leftValues = array(), $rightValues = array())
{
$rangeLength = array_sum($needs);
if (!$rangeLength) {
return array();
Severity: Minor
Found in src/ResolverSeriesGenerator.php - About 45 mins to fix

Function checkLineValuesEqualities has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

protected function checkLineValuesEqualities(array $line)
{
$equality = 0;
foreach ($line as $value) {
if ($value === Grid::ZERO) {
Severity: Minor
Found in src/GridChecker.php - About 35 mins to fix

Function getPossibilities has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

protected static function getPossibilities(array $possibility)
{
$possibilities = array();
foreach (static::$values as $value) {
if (!$possibility['needs'][$value]) {
Severity: Minor
Found in src/ResolverSeriesGenerator.php - About 35 mins to fix

Missing class import via use statement (line '23', column '19').
Open

throw new \InvalidArgumentException('Not exist reverse value for undefined');
Severity: Minor
Found in src/GridHelpers.php by phpmd

Missing class import via use statement (line '133', column '23').
Open

throw new \InvalidArgumentException('The grid should have an even number line.');
Severity: Minor
Found in src/Grid.php by phpmd

Missing class import via use statement (line '41', column '19').
Open

throw new \UnexpectedValueException('Unknown value: ' . $value);
Severity: Minor
Found in src/GridHelpers.php by phpmd
Severity
Category
Status
Source
Language