Showing 19 of 19 total issues
Function upload
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function upload(string $uploader, array $userData)
{
$result = $this->handleUpload();
$can = $this->canDo();
- 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 post
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function post($print_response = true)
{
$upload = isset($_FILES[$this->options['param_name']]) ?
$_FILES[$this->options['param_name']] : null;
if ($upload && is_array($upload['tmp_name'])) {
- 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 afterSave
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function afterSave($event)
{
foreach ($this->fields as $field) {
if ($tmpPath = $this->getTmpFile($field)) {
if (false === is_dir($this->getFolderPath($field))) {
- 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 handleFileUpload
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function handleFileUpload(UploadedFile $uploadedFile)
{
$file = $uploadedFile;
$file->name = (new FileName($this->options['upload_dir'], $this->options['file_name_length'] ?? null))->getFileName($file);
$file->size = (int)$file->size;
- 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 buildTheme
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function buildTheme(): ThemeInterface
{
$theme = null;
if (is_a($this->theme, ThemeInterface::class)) {
- 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 handleUpload
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handleUpload(): array
{
$upload = $this->getUploadData($this->options['param_name']);
if ($upload && is_array($upload['tmp_name'])) {
foreach ($upload['tmp_name'] as $index => $value) {
Function handleUpload
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function handleUpload(): array
{
$upload = $this->getUploadData($this->options['param_name']);
if ($upload && is_array($upload['tmp_name'])) {
foreach ($upload['tmp_name'] as $index => $value) {
- 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 prepareValidators
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function prepareValidators(): array
{
return ArrayHelper::merge([
'FileUploadValidator' => [
'class' => FileUploadValidator::class,
Method handleFileUpload
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handleFileUpload(UploadedFile $uploadedFile)
{
$file = $uploadedFile;
$file->name = (new FileName($this->options['upload_dir'], $this->options['file_name_length'] ?? null))->getFileName($file);
$file->size = (int)$file->size;
Method post
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function post($print_response = true)
{
$upload = isset($_FILES[$this->options['param_name']]) ?
$_FILES[$this->options['param_name']] : null;
if ($upload && is_array($upload['tmp_name'])) {
Function dragAndDrop
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
FileUploadTrigger.prototype.dragAndDrop = function () {
$(document)
.on('dragover', $.proxy(function (e) {
var foundDropzone,
timeout = window.dropZoneTimeout;
Method upload
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function upload(string $uploader, array $userData)
{
$result = $this->handleUpload();
$can = $this->canDo();
Function defaultEvents
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
FileUploadTrigger.prototype.defaultEvents = function () {
this.button
.on('fileuploadprocessalways', $.proxy(function (e, data) {
if (data.files[data.index].error) {
this.input.empty();
Method trim_file_name
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range)
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(string $filePath, string $name, $size, string $type, ?string $error = null, ?int $index = null, ?array $contentRange = null)
Function validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function validate(UploadedFile &$file): bool
{
if ($file->filePath && is_uploaded_file($file->filePath)) {
$fileSize = filesize($file->filePath);
} else {
- 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 prepareFields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function prepareFields()
{
foreach ($this->fields as $field) {
if (false === isset($this->fieldsValues[$field])) {
$file = $this->getTmpRepository()->getFile($field);
- 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 remove
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function remove(string $uploader, array $userData)
{
/** @var UploaderInterface $uploader */
$uploader = new $uploader();
if (false === is_a($uploader, UploaderInterface::class)) {
- 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 decodeServerOptions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function decodeServerOptions($data): array
{
$vars = Yii::$app->session->get($data);
if (false === $vars && isset($_FILES['files'])) {
- 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"