Showing 326 of 326 total issues
Function actionDataBlocks
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function actionDataBlocks()
{
$favs = Yii::$app->adminuser->identity->setting->get("blockfav", []);
$groups = [];
foreach (BlockGroup::find()->with(['blocks'])->all() as $blockGroup) {
- 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 importLayoutFile
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function importLayoutFile($file, $aliased, $themeName = null)
{
if (!file_exists($file)) {
return false;
}
ConcretImplementationBlock
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class ConcretImplementationBlock implements BlockInterface
{
public function onRegister()
{
}
Method testGetProperties
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testGetProperties()
{
PermissionScope::run($this->app, function (PermissionScope $scope) {
$this->createAdminLangFixture();
$this->createCmsNavItemRedirectFixture();
Similar blocks of code found in 2 locations. Consider refactoring. Open
angular.forEach($scope.block.cfgs, function(varItem) {
if (varItem.required && $scope.isEmpty($scope.cfgdata, varItem.var)) {
AdminToastService.error(i18nParam('js_block_attribute_empty', {label: varItem.label}));
response = true;
- 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 91.
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
Method testTeardownWithHidden
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testTeardownWithHidden()
{
$this->createAdminGroupFixture(1);
$this->createAdminUserFixture();
$this->createAdminLangFixture([
Similar blocks of code found in 2 locations. Consider refactoring. Open
angular.forEach($scope.block.vars, function(varItem) {
if (varItem.required && $scope.isEmpty($scope.data, varItem.var)) {
AdminToastService.error(i18nParam('js_block_attribute_empty', {label: varItem.label}));
response = true;
}
- 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 91.
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
Method testDescendentsMultiple
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testDescendentsMultiple()
{
$this->createAdminGroupFixture(1);
$this->createAdminUserFixture();
Method createPageFromDraft
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createPageFromDraft($parentNavId, $navContainerId, $langId, $title, $alias, $description, $fromDraftNavId, $isDraft = false): bool|array
{
if (!$isDraft && empty($isDraft) && !is_numeric($isDraft)) {
$isDraft = 0;
}
Method actionGeneric
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionGeneric()
{
if (Config::has(self::MIGRATION_CODE_100)) {
return $this->outputError("Command already executed. System is up-to-date.");
}
NavController
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class NavController extends \luya\admin\base\RestController
{
private function postArg($name, $defautValue = null)
{
return Yii::$app->request->post($name, $defautValue);
Function controller
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
controller : ['$scope', '$http', '$filter', 'ServiceMenuData', 'ServiceLanguagesData', 'AdminToastService', 'ServiceCurrentWebsite', function($scope, $http, $filter, ServiceMenuData, ServiceLanguagesData, AdminToastService, ServiceCurrentWebsite) {
$scope.error = [];
$scope.success = false;
Function registerToAppView
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function registerToAppView(array $blockAssets, array $assetBundles)
{
$appView = Yii::$app->view;
foreach ($blockAssets as $attribute => $blockAsset) {
- 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 actionGeneric
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function actionGeneric()
{
if (Config::has(self::MIGRATION_CODE_100)) {
return $this->outputError("Command already executed. System is up-to-date.");
}
- 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
NavItemPage
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class NavItemPage extends NavItemType implements NavItemTypeInterface, ViewContextInterface
{
use CacheableTrait;
/**
Function comparePlaceholders
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function comparePlaceholders($array1, $array2)
{
if (!array_key_exists('placeholders', $array1) || !array_key_exists('placeholders', $array2)) {
return 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
Method getBlockItem
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getBlockItem(NavItemPageBlockItem $blockItem, NavItemPage $navItemPage, array $envOptions = [])
{
// if the block relation could be found, return false.
if (!$blockItem->block) {
return false;
Method actionDataBlocks
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function actionDataBlocks()
{
$favs = Yii::$app->adminuser->identity->setting->get("blockfav", []);
$groups = [];
foreach (BlockGroup::find()->with(['blocks'])->all() as $blockGroup) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
136 =>
[
'id' => '136',
'nav_id' => '60',
'lang' => 'fr',
- 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 128.
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
128 =>
[
'id' => '128',
'nav_id' => '89',
'lang' => 'fr',
- 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 128.
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