Showing 4,217 of 4,217 total issues
Similar blocks of code found in 5 locations. Consider refactoring. Open
$data = [
['name' => 'id', 'type' => 'int', 'length' => 10, 'auto_inc' => true],
['name' => 'name', 'type' => 'varchar', 'length' => 255, 'default' => '', 'not_null' => true],
['name' => 'active', 'type' => 'enum', 'length' => '\'0\',\'1\'', 'default' => '0', 'not_null' => true],
['key' => 'primary', 'key_cols' => '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 113.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
<?php
return [
1 => [
'id' => '1',
- 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 113.
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 _on_validate_ok
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _on_validate_ok($params = [], $form)
{
$p = $params ?: $_POST;
$lang = $p['lang'];
$to_export = [];
Method _url_control
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _url_control()
{
if ( ! $this->ALLOW_URL_CONTROL) {
return false;
}
Function payout_provider_change
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
$scope.payout_provider_change = function( $event, provider_id, method_id ) {
$event.stopPropagation();
var action = $scope.action.payout;
if( action.provider_id == provider_id && action.method_id == method_id ) {
$scope.payout_provider_init();
Method load_rate
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function load_rate($options = null)
{
// import options
is_array($options) && extract($options, EXTR_PREFIX_ALL | EXTR_REFS, '');
// var
Method find_all_hooks
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function find_all_hooks($section = 'all')
{
if ( ! in_array($section, ['all', 'user', 'admin'])) {
$section = 'all';
}
Method _show_themes
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _show_themes()
{
$themes = $this->_get_themes();
$num_stpls_array = cache_get($this->CACHE_NAME, 60);
Method _process_where_cond
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _process_where_cond($left, $op, $right)
{
! $op && $op = '=';
$left = trim(strtolower($left));
if (is_string($op)) {
Method _init
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _init()
{
ini_set('html_errors', 0);
// ob_start();
$class = &$this->class;
Method add_watermark
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add_watermark($source_img_path, $watermark_path)
{
$img_info = getimagesize($source_img_path);
$source_mime_type = $this->ALLOWED_MIME_TYPES[$img_info['mime']];
if ( ! $source_mime_type) {
Method coupon_add
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function coupon_add()
{
if (main()->is_post()) {
if ( ! $_POST['code']) {
_re('Code must be entered');
Method get_data
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_data($name = '', $force_ttl = 0, $params = [])
{
DEBUG_MODE && $time_start = microtime(true);
if (empty($name)) {
return null;
Method test_validate_post_empty_value
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function test_validate_post_empty_value()
{
$_SERVER['REQUEST_METHOD'] = 'POST';
$params = ['do_not_remove_errors' => 1];
Method test_with_data
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function test_with_data()
{
$data = [
[
'date' => strtotime('2014-08-12 12:03:19 UTC'),
Method test_rewrite_disabled_simple
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function test_rewrite_disabled_simple()
{
$GLOBALS['PROJECT_CONF']['tpl']['REWRITE_MODE'] = false;
unset($_GET['debug']);
$this->assertEquals('http://' . self::$host . '/?object=test', process_url('./?object=test'));
Function detect_content_type
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function detect_content_type($asset_type, $content = '')
{
$content = trim($content);
$type = false;
if (isset($this->assets[$content])) {
- 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 show
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function show()
{
$all_vars = $this->_get_all_vars();
$total_vars = count((array) $all_vars);
$tr_vars = [];
- 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 time_box
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function time_box($selected = '', $name_postfix = '', $add_str = '', $show_text = 1, $translate = 1)
{
if (is_array($selected)) {
$extra = (array) $extra + $name;
$selected = $extra['selected'];
- 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 _update_user_geo_location
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function _update_user_geo_location($user_id = 0, $FORCE_IP = '')
{
if ( ! main()->USE_GEO_IP) {
return false;
}
- 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"