Showing 356 of 356 total issues
Similar blocks of code found in 3 locations. Consider refactoring. Open
if (document.getElementById('createFavTagInput')) {
document.getElementById('createFavTagInput').addEventListener('blur', event => {
createTagFavorite(event.target as HTMLInputElement);
});
- 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 125.
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
Method generate
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate(Experiments | Items $Entity): void
{
$Teams = new Teams($Entity->Users, $Entity->Users->team);
$Teams->bypassWritePermission = true;
if ($Entity instanceof Experiments) {
Method importRootDataset
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function importRootDataset(array $dataset): void
{
$createTarget = $this->targetNumber;
$title = $this->transformIfNecessary($dataset['name'] ?? _('Untitled'));
Function formatMetadata
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public static function formatMetadata(string $json): string
{
$final = '';
$Metadata = new Metadata($json);
$extraFields = $Metadata->getExtraFields();
- 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 edit.ts
has 329 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 getSettingsByIdp
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getSettingsByIdp(array $idp): array
{
$idpSigningCerts = array($idp['x509']);
if (!empty($idp['x509_new'])) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
enum Target {
All = 'all',
Body = 'body',
Comment = 'comments',
ContentType = 'content_type',
- 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 111.
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
enum Model {
Apikey = 'apikeys',
Comment = 'comments',
Config = 'config',
FavTag = 'favtags',
- 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 111.
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
File show.ts
has 321 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
File plugin.js
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
class AutoComplete {
editor;
options = {};
query = '';
hasFocus = true;
File EntitySqlBuilder.php
has 315 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @author Nicolas CARPi <nico-git@deltablot.email>
* @copyright 2022 Nicolas CARPi
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')) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else if (el.matches('[data-action="destroy-template"]')) {
if (confirm(i18next.t('generic-delete-warning'))) {
TemplateC.destroy(parseInt(el.dataset.id))
.then(() => window.location.replace('team.php?tab=3'))
.catch((e) => notif({'res': false, 'msg': e.message}));
- 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 100.
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
} else if (el.matches('[data-action="destroy-template"]')) {
if (confirm(i18next.t('generic-delete-warning'))) {
EntityC.destroy(parseInt(el.dataset.id))
.then(() => window.location.replace('ucp.php?tab=3'))
.catch((e) => notif({'res': false, 'msg': e.message}));
- 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 100.
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
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();