Showing 125 of 127 total issues
Function mounted
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
mounted(el: TooltipElement, binding: any) {
let placement = 'bottom';
if (placements.includes(binding.arg)) {
placement = binding.arg;
} else if (binding.arg) {
Method launchPlugins
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function launchPlugins(?bool $protected = null): void
{
$this->getAllPlugins()->each(function (GenericPlugin $plugin) use ($protected) {
$start = round(microtime(true) * 1000);
$plugin->stats = [
Method handle
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handle(PluginManager $pluginmanager)
{
$name = $this->argument('plugin');
if (!is_string($name)) {
Method getModelRelationships
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getModelRelationships(\ReflectionClass $reflection, Model $model, bool $resolve = false): Collection
{
$single = [
BelongsTo::class,
HasOne::class,
File Plugins.php
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Voyager\Admin\Manager;
use Composer\InstalledVersions;
Method transformResults
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function transformResults(Layout $layout, bool $translatable, mixed $query, ?string $global, mixed $filters): mixed
{
return $query->transform(function ($item) use ($translatable, $layout) {
$item->primary_key = $item->getKey();
if ($translatable) {
Method data
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function data(Request $request): array
{
$start = microtime(true);
$bread = $this->getBread($request);
$forcedLayout = $request->get('forcedLayout', null);
Function set
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function set(string $key, mixed $value, ?string $locale = null, bool $save = true): void
{
$this->load();
$setting = $this->getSettingsByKey($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"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
Array.prototype.whereNot = function (prop, value = undefined) {
return this.filter(function (el) {
if (value !== undefined) {
return el[prop] !== value;
}
- 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 72.
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
Array.prototype.where = function (prop, value = undefined) {
return this.filter(function (el) {
if (value !== undefined) {
return el[prop] == value;
}
- 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 72.
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 createVoyager
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
window.createVoyager = (data: VoyagerData, el = 'voyager') => {
createInertiaApp({
resolve: name => {
// This is necessary so webpack doesn't load ALL components (by using require(`@components/${name}`))
let component = require(`@components/Generic.vue`).default;
- 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 boot
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function boot(Router $router): void
{
$router->aliasMiddleware('voyager.admin', VoyagerAdminMiddleware::class);
$this->registerResources();
Function createVoyager
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
window.createVoyager = (data: VoyagerData, el = 'voyager') => {
createInertiaApp({
resolve: name => {
// This is necessary so webpack doesn't load ALL components (by using require(`@components/${name}`))
let component = require(`@components/Generic.vue`).default;
Function update
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function update(Request $request, $table)
{
$bread = $request->bread;
$exists = $this->breadmanager->getBread($table);
- 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 registerActions
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function registerActions()
{
$breadmanager = $this->breadmanager;
$read_action = (new Action('voyager::generic.read', 'book-open', null, 'accent'))
Method getThumbnailDefinitions
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getThumbnailDefinitions()
{
$thumbs = collect(VoyagerFacade::setting('thumbnails'));
return $thumbs->map(function ($thumb, $name) {
Method addPlugin
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addPlugin(string|GenericPlugin $plugin): void
{
$start = round(microtime(true) * 1000);
if (!$this->enabled_plugins) {
$this->loadEnabledPlugins();
Method update
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update(Request $request, $table)
{
$bread = $request->bread;
$exists = $this->breadmanager->getBread($table);
Method getViewData
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getViewData(): array
{
// This data gets directly written to the store and can be accessed through `this.$store` everywhere
$viewData = [
'localization' => $this->getLocalization(),
Function processUploadedFile
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function processUploadedFile($file, $path)
{
$name = '';
$count = 0;
$thumbnails = 0;
- 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"