Showing 60 of 60 total issues
File Client.php
has 435 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package gooddata-php-client
* @copyright Keboola
* @author Jakub Matejka <jakub@keboola.com>
Function diff
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
public function diff($pid, $model)
{
$uri = "/gdc/projects/$pid/model/diff?includeDeprecated=true&includeGrain=true";
$result = $this->client->post($uri, ['diffRequest' => ['targetModel' => $model]]);
- Read upRead up
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
Function normalizeModel
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public function normalizeModel($model)
{
foreach ($model['projectModel']['datasets'] as &$d) {
if (isset($d['dataset']['anchor']['attribute']['labels'])) {
foreach ($d['dataset']['anchor']['attribute']['labels'] as &$l) {
- Read upRead up
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 unaccent
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function unaccent($string)
{
if (!preg_match('/[\x80-\xff]/', $string)) {
return $string;
}
Method getDataLoadManifest
has 119 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getDataLoadManifest(
$identifier,
array $columns,
$incrementalLoad = false
) {
Client
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
class Client
{
/**
* Number of retries for one API call
*/
Function getDataLoadManifest
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public static function getDataLoadManifest(
$identifier,
array $columns,
$incrementalLoad = false
) {
- Read upRead up
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
$handlerStack->push(Middleware::retry(
function ($retries, RequestInterface $request, ResponseInterface $response = null, $error = null) {
if ($retries >= self::RETRIES_COUNT) {
return false;
} elseif ($response && $response->getStatusCode() > 499) {
- Read upRead up
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 144.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
$handlerStack->push(Middleware::retry(
function ($retries, RequestInterface $request, ResponseInterface $response = null, $error = null) {
if ($retries >= self::RETRIES_COUNT) {
return false;
} elseif ($response && $response->getStatusCode() > 499) {
- Read upRead up
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 144.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File Projects.php
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package gooddata-php-client
* @copyright Keboola
* @author Jakub Matejka <jakub@keboola.com>
Function pollEtlTask
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function pollEtlTask($uri)
{
$try = 1;
do {
sleep(min(pow(2, $try), rand(15, 20)));
- Read upRead up
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
Function request
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function request($method, $uri, $params = [], $retries = 5)
{
$startTime = time();
$options = $this->guzzleOptions;
- Read upRead up
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 diff
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function diff($pid, $model)
{
$uri = "/gdc/projects/$pid/model/diff?includeDeprecated=true&includeGrain=true";
$result = $this->client->post($uri, ['diffRequest' => ['targetModel' => $model]]);
Function getToFile
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function getToFile($uri, $filename, $retries = 20)
{
$this->refreshToken();
$startTime = time();
- Read upRead up
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
Function update
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function update($pid, $model, $dryRun = false, $multivalueAttributes = [])
{
$model = $this->normalizeModel($model);
$update = $this->diff($pid, $model);
- Read upRead up
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
Function seemsUtf8
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function seemsUtf8($string)
{
for ($i = 0; $i < strlen($string); $i++) {
if (ord($string[$i]) < 0x80) {
continue; # 0bbbbbbb
- Read upRead up
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
Function saveLogs
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function saveLogs($folderName, $logFile)
{
$errors = [];
$uploadFile = "$folderName/upload_status.json";
- Read upRead up
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 Datasets.php
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package gooddata-php-client
* @copyright Keboola
* @author Jakub Matejka <jakub@keboola.com>
Method getToFile
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getToFile($uri, $filename, $retries = 20)
{
$this->refreshToken();
$startTime = time();
Method __construct
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct($username, $password, $url = '')
{
$this->username = $username;
$this->password = $password;