Showing 203 of 288 total issues
Method handle
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function handle(UserRepo $userRepo): int
{
$details = $this->snakeCaseOptions();
if (empty($details['email'])) {
Method applySortUpdates
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function applySortUpdates(BookSortMapItem $sortMapItem, array $modelMap): void
{
/** @var BookChild $model */
$model = $modelMap[$sortMapItem->type . ':' . $sortMapItem->id] ?? null;
if (!$model) {
Method build
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function build(): array
{
$page = clone $this->page;
$isDraft = boolval($this->page->draft);
$templates = $this->queries->pages->visibleTemplates()
Function updateIdsRecursively
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function updateIdsRecursively(DOMNode $element, int $depth, array &$idMap, array &$changeMap): void
{
/* @var DOMNode $child */
foreach ($element->childNodes as $child) {
if ($child instanceof DOMElement && ($depth === 0 || in_array($child->nodeName, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']) || $child->getAttribute('id'))) {
- 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 setupBookSortable
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setupBookSortable(bookContainer) {
const sortElems = Array.from(bookContainer.querySelectorAll('.sort-list, .sortable-page-sublist'));
const bookGroupConfig = {
name: 'book',
Function gatherPlugins
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function gatherPlugins(options) {
const plugins = [
'image',
'table',
'link',
Function getSetupCallback
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getSetupCallback(options) {
return function setupCallback(editor) {
function editorChange() {
if (options.darkMode) {
editor.contentDocument.documentElement.classList.add('dark-mode');
Method loadModelsFromSortMap
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function loadModelsFromSortMap(BookSortMap $sortMap): array
{
$modelMap = [];
$ids = [
'chapter' => [],
Method show
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function show(string $bookSlug, string $pageSlug)
{
try {
$page = $this->queries->findVisibleBySlugsOrFail($bookSlug, $pageSlug);
} catch (NotFoundException $e) {
Function setupListeners
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setupListeners() {
const keyboardNavHandler = new KeyboardNavigationHandler(this.container, event => {
this.hide();
this.toggle.focus();
if (!this.bubbleEscapes) {
Method handle
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function handle(PermissionsUpdater $permissionsUpdater, BookshelfQueries $queries): int
{
$shelfSlug = $this->option('slug');
$cascadeAll = $this->option('all');
$shelves = null;
Method rules
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function rules(int $userId = null): array
{
return [
'create' => [
'name' => ['required', 'min:2', 'max:100'],
Function setupListeners
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setupListeners() {
// Copy on copy button click
this.includeButton.addEventListener('click', () => copyTextToClipboard(this.includeInput.value));
this.linkButton.addEventListener('click', () => copyTextToClipboard(this.linkInput.value));
Method orientImageToOriginalExif
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function orientImageToOriginalExif(InterventionImage $image, string $originalData): void
{
if (!extension_loaded('exif')) {
return;
}
Function detailsDialog
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function detailsDialog(editor) {
return {
title: 'Edit collapsible block',
body: {
type: 'panel',
Method handleLoginCallback
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function handleLoginCallback(string $socialDriver, SocialUser $socialUser)
{
$socialDriver = trim(strtolower($socialDriver));
$socialId = $socialUser->getId();
Method registerUser
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function registerUser(array $userData, ?SocialAccount $socialAccount = null, bool $emailConfirmed = false): User
{
$userEmail = $userData['email'];
$authSystem = $socialAccount ? $socialAccount->driver : auth()->getDefaultDriver();
Function setupCallback
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
return function setupCallback(editor) {
function editorChange() {
if (options.darkMode) {
editor.contentDocument.documentElement.classList.add('dark-mode');
}
Method searchEntities
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function searchEntities(SearchOptions $searchOpts, string $entityType = 'all', int $page = 1, int $count = 20): array
{
$entityTypes = array_keys($this->entityProvider->all());
$entityTypesToSearch = $entityTypes;
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function update(Request $request, int $id)
{
$this->preventAccessInDemoMode();
$this->checkPermission('users-manage');