Showing 4,293 of 4,293 total issues
Function save
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function save($new, $old)
{
if (is_array($new) && is_array($old)) {
$nc = count($new);
$oc = count($old);
- 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 evaluateGroupKey
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function evaluateGroupKey($args, &$key)
{
//check for special key syntax like group::key
if (preg_match("/^(.*?)::/i", $key, $out)) {
if (is_array($out) && count($out) == 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 prepareAttachment
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function prepareAttachment($att)
{
$attachment = null;
if ((is_string($att) && is_numeric($att)) || is_int($att)) {
- 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 recalibrate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
recalibrate: function () {
var winH,
conH,
position,
winDiff;
Function sync
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
sync: function (context) {
var that = this;
KB.Events.trigger('field.before.sync', this.model);
var clone = that.toJSON();
Function createModule
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
createModule: function (module) {
var Area, data;
// check if capability is right for this action
if (Checks.userCan('create_kontentblocks')) {
} else {
Function bindHandlers
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
bindHandlers: function () {
var handlers, checkCounts;
media.view.MediaFrame.Select.prototype.bindHandlers.apply(this, arguments);
Function init
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
init: function () {
var that = this;
var $body = $('body');
// init general ui components
this.initTabs();
Method prepareFormValue
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function prepareFormValue($val)
{
if (is_numeric($val)) {
return filter_var($val, FILTER_SANITIZE_NUMBER_INT);
} else if (is_string($val)) {
Method markVisibility
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function markVisibility(Field $field)
{
$field->setVisibility(true);
$postType = $this->entity->context->get('postType');
Method resize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function resize($args = array())
{
if ($this->isSVG) {
$this->src = $this->attachment['url'];
return $this;
Method setupMediaElements
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function setupMediaElements()
{
$images = [];
foreach ($this->value['images'] as $k => $attId) {
if (is_numeric($attId['id'])) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
Stack.prototype.last = function () {
if (this.items.length > 0) {
return this.items.pop();
}
return null;
- 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 56.
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
Stack.prototype.first = function () {
if (this.items.length > 0) {
return this.items.shift();
}
return null;
- 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 56.
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
Function render
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
render: function () {
// append wrapper element
this.ModuleView.$el.append(tplModuleControls({
model: this.ModuleView.model.toJSON(),
i18n: KB.i18n.jsFrontend
Function geocode
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
geocode: function(query, cb, context) {
getJSON(
this.options.serviceUrl + '/address',
{
key: this._key,
Function create
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
create: function (ui) {
var Area, data, module;
// check if capability is right for this action
if (Checks.userCan('create_kontentblocks')) {
} else {
Function geocode
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
geocode: function(query, cb, context) {
getJSON(
this.options.serviceUrl + '/address',
{
key: this._key,
Function initialSetup
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
initialSetup: function () {
var that = this;
var data = this.model.get('value').images || {};
data = _.filter(data, function(d){
Method form
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function form()
{
$masterId = $this->properties->parentObjectId;
$translated = false;
$icl = get_post_meta(get_the_ID(), '_icl_lang_duplicate_of', true);