Showing 125 of 127 total issues
Function setSettings
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
private function setSettings(SettingManager $settingsmanager): void
{
$path = realpath(__DIR__.'/../../resources/presets/settings.json');
if ($path !== false) {
$content = file_get_contents($path);
- 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 install
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
install(app: Voyager) {
app.config.globalProperties.__ = function (key: string, replace = {}) {
return this.trans(key, replace);
};
app.config.globalProperties.trans = function (key: string, replace = {}) {
- 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 BreadController.php
has 376 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Voyager\Admin\Http\Controllers;
use DB;
File MediaController.php
has 369 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Voyager\Admin\Http\Controllers;
use Illuminate\Http\Request;
File Breads.php
has 357 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Voyager\Admin\Manager;
use Illuminate\Container\Container;
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
namespace Voyager\Admin\Formfields;
use Voyager\Admin\Classes\Formfield;
- 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 173.
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
<?php
namespace Voyager\Admin\Formfields;
use Voyager\Admin\Classes\Formfield;
- 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 173.
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 install
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
install(app: Voyager) {
app.config.globalProperties.toggleDirection = function () {
Store.rtl = !Store.rtl;
if (Store.rtl) {
document.querySelector('html')?.setAttribute('dir', 'rtl');
- 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 listFiles
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function listFiles(Request $request)
{
$hide_thumbnails = VoyagerFacade::setting('media.hide-thumbnails', true);
$thumbnail_names = $this->getThumbnailDefinitions()->pluck('name')->transform(function ($name) {
return '_'.$name;
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
namespace Voyager\Admin\Formfields;
use Voyager\Admin\Classes\Formfield;
- 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 156.
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
<?php
namespace Voyager\Admin\Formfields;
use Voyager\Admin\Classes\Formfield;
- 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 156.
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 VoyagerServiceProvider.php
has 316 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Voyager\Admin;
use Illuminate\Contracts\Auth\Access\Gate;
Function handle
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function handle(PluginManager $pluginmanager)
{
$name = $this->argument('plugin');
if (!is_string($name)) {
- 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 prepareVoyager
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
function prepareVoyager(data: VoyagerData) {
for (let key of Object.keys(data)) {
// @ts-ignore
Store[key] = data[key];
}
Breads
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class Breads
{
protected Collection $formfields;
protected string $path;
protected ?Collection $breads = null;
Method relationship
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function relationship(Request $request): array
{
// TODO: Validate that the method exists in edit/add layout
$bread = $this->getBread($request, true);
list($perPage, $query, $method, $column) = array_values($request->only(['perPage', 'query', 'method', 'column', 'key']));
Function install
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
install(app: Voyager) {
app.config.globalProperties.toggleDirection = function () {
Store.rtl = !Store.rtl;
if (Store.rtl) {
document.querySelector('html')?.setAttribute('dir', 'rtl');
Method processUploadedFile
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processUploadedFile($file, $path)
{
$name = '';
$count = 0;
$thumbnails = 0;
Function install
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
install(app: Voyager) {
app.config.globalProperties.__ = function (key: string, replace = {}) {
return this.trans(key, replace);
};
app.config.globalProperties.trans = function (key: string, replace = {}) {
Function relationship
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function relationship(Request $request): array
{
// TODO: Validate that the method exists in edit/add layout
$bread = $this->getBread($request, true);
list($perPage, $query, $method, $column) = array_values($request->only(['perPage', 'query', 'method', 'column', 'key']));
- 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"