Showing 139 of 139 total issues
Function indexBody
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function indexBody($query = null)
{
$fields = $this->parseVisibleFields($this->parseFields($this->fields()));
$sortBy = array_keys($fields)[0];
$query = $query;
- 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 Country.php
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Grafite\Forms\Fields\Bootstrap;
use Grafite\Forms\Fields\Bootstrap\Select;
Method handler
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handler($content)
{
$convertor = new HtmlConvertor([
'raw' => function ($html) {
return $html;
Method js
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function js($id, $options)
{
return <<<JS
_formsjs_editorField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
Method styles
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function styles($id, $options)
{
$colorVariable = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? '--bs-primary' : '--primary';
$position = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? 'relative' : 'absolute';
$labelSpacing = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? ".form-check-label[for=\"{$id}\"] {margin-left: -24px;}" : '';
Similar blocks of code found in 3 locations. Consider refactoring. Open
_fields[i].addEventListener("change", function (e) {
if (this.value.length > 0) {
this.classList.remove('_formValidationClass');
if (this.nextSibling) {
this.nextSibling.remove();
- 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 81.
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 3 locations. Consider refactoring. Open
_fields[i].addEventListener("keyup", function (e) {
if (this.value.length > 0) {
this.classList.remove('_formValidationClass');
if (this.nextSibling) {
this.nextSibling.remove();
- 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 81.
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 3 locations. Consider refactoring. Open
_fields[i].addEventListener("onfocusout", function (e) {
if (this.value.length > 0) {
this.classList.remove('_formValidationClass');
if (this.nextSibling) {
this.nextSibling.remove();
- 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 81.
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 makeSelect
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function makeSelect($name, $selected, $options)
{
$selectOptions = '';
if (isset($options['attributes']['value'])) {
Function indexHeaders
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function indexHeaders()
{
$headers = '';
$columns = (! empty($this->indexColumns())) ? $this->indexColumns() : $this->parseVisibleFields($this->parseFields($this->fields()));
- 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 onLoadJsData
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function onLoadJsData($id, $options)
{
$route = null;
if (isset($options['upload_route'])) {
Function _formsjs_trigger_onclick_function
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
window._formsjs_trigger_onclick_function = function (event) {
event.preventDefault();
let _form = event.target.form;
let _method = event.target.getAttribute('data-formsjs-onclick');
- 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 js
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function js($id, $options)
{
return <<<JS
_formsjs_grapesjsField = function (element) {
if (! element.getAttribute('data-formsjs-rendered')) {
File Country.php
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Grafite\Forms\Fields;
use Grafite\Forms\Fields\AutoSuggestSelect;
File WizardForm.php
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Grafite\Forms\Forms;
class WizardForm extends HtmlForm
Method action
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function action($method, $route, $button = 'Send', $options = [], $asModal = false, $disableOnSubmit = false, $submitViaAjax = false)
{
if (! is_null($this->submitViaAjax)) {
$submitViaAjax = $this->submitViaAjax;
}
Method styles
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function styles($id, $options)
{
$themes = [];
$themes['light'] = <<<CSS
Method edit
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function edit($model = null)
{
if (! is_null($model)) {
$this->setInstance($model);
}
Method indexBody
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function indexBody($query = null)
{
$fields = $this->parseVisibleFields($this->parseFields($this->fields()));
$sortBy = array_keys($fields)[0];
$query = $query;
Method js
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function js($id, $options)
{
return <<<JS
_formsjs_trixField = function (element) {
element.addEventListener('grafite-form-change', function (event) {