Showing 221 of 356 total issues
Function handleEvent
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
handleEvent(event: Event): Promise<Response> | boolean {
const el = event.target as HTMLFormElement;
if (el.reportValidity() === false || el.hasAttribute('readonly')) {
return false;
}
- 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 dbInsert
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
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)
- 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 getResponse
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getResponse(): Response
{
try {
$this->parseReq();
Method getResponse
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function getResponse(): Response
{
// this will disable output buffering and prevent issues when downloading big files
if (ob_get_level()) {
ob_end_clean();
Function init
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
init() {
// CREATE EXPERIMENT or DATABASE item with shortcut
// could work from anywhere but limit it to experiments|database pages
key(this.create, () => {
Method importFile
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function makeSortable
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public makeSortable(table: HTMLTableElement): void {
// do not parse table twice, e.g. while loading entry bodies via toggle-body button
if (table.dataset.sortingActivated === 'true') {
return;
}
Method getTeamWhereClause
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function getTeamWhereClause(EntityType $model): string
{
// add team id filter for items + pub/org visibility filter
$sql = sprintf(
"%s AND (
Function imagesUploadHandler
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const imagesUploadHandler = (blobInfo): Promise<string> => new Promise((resolve, reject) => {
// Edgecase for editing an image using tinymce ImageTools
// Check if it was selected. This is set by an event hook below
if (tinymceEditImage.selected === true) {
// Note: confirm will trigger the SelectionChange event hook below again
Method getAllEmailAddressesRawData
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static function getAllEmailAddressesRawData(EmailTarget $target, ?int $targetId = null): array
{
$select = 'SELECT DISTINCT users.userid, email, CONCAT(firstname, " ", lastname) AS fullname FROM users';
switch($target) {
case EmailTarget::Team:
Method getHtml
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function getHtml(): string
{
$date = new DateTimeImmutable($this->Entity->entityData['date'] ?? date('Ymd'));
$locked = $this->Entity->entityData['locked'];
Method view
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function view(): Response
{
// by default the id is taken from the URL
$id = $this->App->Request->query->getInt('id');
// but if we have an access_key we might be able to bypass read permissions
Function eventClick
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
eventClick: function(info): void {
if (!editable) {
// load page with selected item + correct start depending on current view
window.location.replace(`team.php?tab=1&item=${info.event.extendedProps.items_id}&start=${calendar.view.activeStart.toISOString()}`);
return;
Method execute
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function execute(InputInterface $input, OutputInterface $output): int
{
$Db = Db::getConnection();
$req = $Db->q('SELECT COUNT(*) AS cnt FROM information_schema.tables WHERE table_schema = "' . Config::fromEnv('DB_NAME') . '"');
Method readGroupsWithUsersFromUser
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function readGroupsWithUsersFromUser(): array
{
$sql = "SELECT team_groups_of_user.name,
teams.name AS team_name,
JSON_ARRAYAGG(JSON_OBJECT(
Function convertToFeaturedDNASequence
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const convertToFeaturedDNASequence = function(openVESequence): void {
data.sequenceData = {
features: [],
sequence: openVESequence.sequence,
};
Function handleEvent
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
handleEvent(event: Event): Promise<Response> | boolean {
const el = event.target as HTMLFormElement;
if (el.reportValidity() === false || el.hasAttribute('readonly')) {
return false;
}
Function factory
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
factory: require => {
const { PosixFS } = require('@yarnpkg/fslib');
const { ZipOpenFS } = require('@yarnpkg/libzip');
const libzip = require('@yarnpkg/libzip').getLibzipSync();
const { structUtils, Cache } = require('@yarnpkg/core');
Method readFromQuery
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function readFromQuery(
string $query,
int $teamId = 0,
bool $includeArchived = false,
bool $onlyAdmins = false,
Method patch
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function patch(Action $action, array $params): array
{
$this->canWriteOrExplode($action);
match ($action) {
Action::Add => (