Showing 221 of 356 total issues
Users
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class Users implements RestInterface
{
public bool $needValidation = false;
public array $userData = array();
QueryBuilderVisitor
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class QueryBuilderVisitor implements Visitor
{
public function buildWhere(Visitable $parsedQuery, VisitorParameters $parameters): WhereCollector
{
return $parsedQuery->accept($this, $parameters);
Method createOne
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createOne(
string $email,
array $teams,
string $firstname = '',
string $lastname = '',
Function edit
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
edit(): Promise<void> {
return this.read().then(json => {
this.editor.refresh(json as ValidMetadata);
// do nothing more if there is no extra_fields in our json
if (!Object.prototype.hasOwnProperty.call(json, 'extra_fields')) {
AutoComplete
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class AutoComplete {
editor;
options = {};
query = '';
hasFocus = true;
Method notif
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function notif(array $notif): string
{
$relativeMoment = '<br><span class="relative-moment" title="%s"></span>';
return match (Notifications::from($notif['category'])) {
Method formatMetadata
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function formatMetadata(string $json): string
{
$final = '';
$Metadata = new Metadata($json);
$extraFields = $Metadata->getExtraFields();
Method execute
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output): int
{
$Db = Db::getConnection();
$queryItemsOrExperiment = "SELECT DISTINCT `id`, `body`, `userid`
File TeamGroups.php
has 291 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package Elabftw\Elabftw
* @author Nicolas CARPi <nico-git@deltablot.email>
File Eln.php
has 289 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Nicolas CARPi <nico-git@deltablot.email>
* @copyright 2022 Nicolas CARPi
Function tryAuth
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function tryAuth(): AuthResponse
{
$record = $this->getRecord();
$dn = $record->getDn();
if ($dn === null) {
- 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 team.ts
has 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @author Nicolas CARPi <nico-git@deltablot.email>
* @copyright 2012 Nicolas CARPi
* @see https://www.elabftw.net Official website
* @license AGPL-3.0
Method create
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create(int $template = -1, array $tags = array()): int
{
$Templates = new Templates($this->Users);
$Teams = new Teams($this->Users);
$teamConfigArr = $Teams->readOne();
File Apiv2Controller.php
has 283 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Nicolas CARPi <nico-git@deltablot.email>
* @copyright 2022 Nicolas CARPi
Function execFile
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function execFile(string $filename, bool $force = false): int
{
if ($this->output !== null) {
// add two for the spaces around
$len = strlen($filename) + 2;
- 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 importFile
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function importFile(array $file): void
{
// note: path transversal vuln is detected and handled by flysystem
$filepath = $this->tmpPath . '/' . basename($this->root) . '/' . $file['@id'];
// checksum is mandatory for import
- 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 getTwig
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getTwig(bool $debug): Environment
{
// load templates
$loader = new FilesystemLoader(dirname(__DIR__, 2) . '/src/templates');
Function setup
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
setup: (editor: Editor): void => {
// holds the timer setTimeout function
let typingTimer;
// make the edges round
editor.on('init', () => editor.getContainer().className += ' rounded');
Method visitTimestampField
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function visitTimestampField(TimestampField $timestampField, VisitorParameters $parameters): WhereCollector
{
$query = '';
$bindValues = array();
Method dbInsert
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function dbInsert($item): void
{
$Teams = new Teams($this->Users, $this->Users->userData['team']);
// the body is updated after it has been fixed by the uploaded files with correct long_name
$sql = 'INSERT INTO items(team, title, date, userid, category, status, canread, canwrite, canbook, elabid, metadata)