Showing 18 of 18 total issues
Method createPage
has 136 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createPage($title, $layoutViewFile, array $layoutPlaceholders, array $options = [])
{
$id = ArrayHelper::getValue($options, 'id', 1);
$parentNavId = ArrayHelper::getValue($options, 'parentNavId', 0);
$isHome = ArrayHelper::getValue($options, 'isHome', true);
Function createSchemaFromRules
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function createSchemaFromRules()
{
$object = $this->getNewModel();
$fields = [];
- 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 AdminDatabaseTableTrait.php
has 315 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace luya\testsuite\traits;
use luya\admin\models\Group;
File NgRestTestCase.php
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace luya\testsuite\cases;
use yii\base\InvalidConfigException;
ServerTestCase
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class ServerTestCase extends BaseTestSuite
{
/**
* @var string
*/
Function compareMessages
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function compareMessages($folder, $masterLang)
{
$folder = Yii::getAlias($folder);
$folders = [];
- 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 mockBasicAdminModels
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function mockBasicAdminModels()
{
$this->createAdminUserGroupTable();
$this->createAdminGroupAuthTable();
$this->createAdminAuthTable();
Method actionIndex
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionIndex()
{
if ($this->mode === null) {
$this->mode = $this->select('Table or Model (ActiveRecord) based Fixture', [
self::MODE_MODEL => 'Model (Active Record)',
Method prepare
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function prepare()
{
// ensure the given and required application components are available.
$this->updateApplicationConfig();
Method createAdminUserFixture
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createAdminUserFixture(array $fixtureData = [], $defaultSchema = true)
{
return new NgRestModelFixture([
'modelClass' => User::class,
'schema' => $defaultSchema ? [
Method createSchemaFromRules
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createSchemaFromRules()
{
$object = $this->getNewModel();
$fields = [];
Method testBasicNgRestMethods
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testBasicNgRestMethods()
{
$class = $this->modelClass;
$this->assertNotNull($class::ngRestApiEndpoint());
Method itemToStructure
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function itemToStructure($item, $lang, $parentNavId)
{
$id = ArrayHelper::getValue($item, 'id');
$title = ArrayHelper::getValue($item, 'title');
return [
Similar blocks of code found in 2 locations. Consider refactoring. Open
'navItemPage1' => [
'id' => "{$id}002",
'nav_id' => 1,
'lang_id' => 1,
'nav_item_type' => NavItem::TYPE_MODULE,
- 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 99.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
'navItemPage1' => [
'id' => "{$id}003",
'nav_id' => 1,
'lang_id' => 1,
'nav_item_type' => NavItem::TYPE_REDIRECT,
- 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 99.
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
Function actionIndex
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function actionIndex()
{
if ($this->mode === null) {
$this->mode = $this->select('Table or Model (ActiveRecord) based Fixture', [
self::MODE_MODEL => 'Model (Active Record)',
- 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 generateClassFile
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function generateClassFile(TableSchema $schema, $className, array $data, $modelClass = null, $tableName = null, $addData = null)
Method assignGroupAuth
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function assignGroupAuth($groupId, $authId, $canCreate = true, $canUpdate = true, $canDelete = true)