Showing 844 of 844 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (
isset($fields['filter'][$section_id]['system:id'])
|| isset($fields['filter'][$section_id]['id'])
) {
$id = isset($fields['filter'][$section_id]['system:id'])
- 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 264.
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
if (
isset($fields['filter'][$section_id]['system:creation-date'])
|| isset($fields['filter'][$section_id]['system:date'])
) {
$creation_date = isset($fields['filter'][$section_id]['system:creation-date'])
- 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 264.
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 class.installer.php
has 535 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package install
*/
File field.taglist.php
has 526 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package toolkit
*/
Method install
has 215 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function install()
{
$db = null;
$fields = $this->extendDatabaseFields(self::$POST['fields']);
$start = time();
Function __viewIndex
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
public function __viewIndex()
{
$canonical_link = '/system/extensions/';
$this->setPageType('table');
$this->setTitle(__('%1$s – %2$s', array(__('Extensions'), __('Symphony'))));
- 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 __buildPage
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
private function __buildPage($page)
{
$is_logged_in = static::isLoggedIn();
if (empty($page) || is_null($page)) {
- 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 content.blueprintsevents.php
has 501 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package content
*/
Function symphonyDuplicator
has 200 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.symphonyDuplicator = function(options) {
var objects = this,
settings = {
instances: '> li:not(.template)',
templates: '> li.template',
General
has 53 functions (exceeds 20 allowed). Consider refactoring. Open
class General
{
/**
* Convert any special characters into their entity equivalents. Since
* Symphony 2.3, this function assumes UTF-8 and will not double
Function symphonyDrawer
has 187 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.symphonyDrawer = function(options) {
var objects = this,
wrapper = $('#wrapper'),
contents = $('#contents'),
form = contents.find('> form'),
Function __form
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
public function __form()
{
// Handle unknown context
if (!in_array($this->_context['action'], array('new', 'edit'))) {
Administration::instance()->errorPageNotFound();
- 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 upgrade
has 185 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function upgrade()
{
// Upgrade DB settings
$db = Symphony::Configuration()->get('database');
$db['driver'] = 'mysql';
Method __viewEdit
has 184 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __viewEdit()
{
if (!$section_id = SectionManager::fetchIDFromHandle($this->_context['section_handle'])) {
Administration::instance()->throwCustomError(
__('The Section, %s, could not be found.', array('<code>' . $this->_context['section_handle'] . '</code>')),
File field.author.php
has 473 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package toolkit
*/
File class.frontendpage.php
has 467 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package toolkit
*/
Function symphonyCollapsible
has 178 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.symphonyCollapsible = function(options) {
var objects = this,
settings = {
items: '.instance',
handles: '.frame-header',
Function __formAction
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
public function __formAction()
{
$fields = $_POST['fields'];
$this->_errors = array();
$providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::EVENT);
- 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 duplicators
has 177 lines of code (exceeds 25 allowed). Consider refactoring. Open
objects.each(function duplicators() {
var duplicator = $(this),
list = duplicator.find('> ol'),
apply = $('<fieldset class="apply" />'),
selector = $('<select />'),
Method __actionNew
has 174 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __actionNew()
{
if (is_array($_POST['action']) && array_key_exists('save', $_POST['action'])) {
$canProceed = true;
$edit = ($this->_context['action'] === "edit");