Showing 105 of 127 total issues
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
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"
Further reading
Function applyCustomScope
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function applyCustomScope(Bread $bread, Layout $layout, mixed $filter, mixed $query, array &$warnings): mixed
{
if (!is_null($filter) && is_array($filter)) {
// Validate filter exists in layout
if (collect($layout->options->filters)->where('column', $filter['column'])->where('operator', $filter['operator'])->where('value', $filter['value'])->count() > 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"
Further reading
Method edit
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function edit(Request $request, mixed $id): InertiaResponse
{
$bread = $this->getBread($request, true);
$layout = $this->breadmanager->getLayoutForAction($bread, 'edit');
Method setSettings
has 34 lines of code (exceeds 25 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);
Function mounted
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
mounted(el, binding) {
el.addEventListener('click', (e) => {
let content = document.getElementById('content');
let element = document.getElementById('top');
if (binding.value !== '') {
Method updateStoreData
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updateStoreData(Collection $formfields, mixed $data, mixed $model, bool $update = true): mixed
{
$formfields->each(function ($formfield) use ($data, &$model, $update) {
$value = $data[$formfield->column->column] ?? '';
Method validateData
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function validateData(Collection $formfields, array|Collection $data, bool $all_locales = false): array
{
$errors = [];
$formfields->each(function ($formfield) use (&$errors, $data, $all_locales) {