Showing 4,217 of 4,217 total issues
Method _get_modules_from_files
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _get_modules_from_files($include_framework = true, $with_sub_modules = false)
{
$modules = [];
$yf_prefix_len = strlen(YF_PREFIX);
Method category_revisions_view
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function category_revisions_view()
{
$type = 'category';
$db_revision = $this->get_revision_db($type);
$id = (int) $_GET['id'];
Method download_dir
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function download_dir($server_info = [], $remote_dir = '', $local_dir = '', $pattern_include = '', $pattern_exclude = '', $level = null)
{
$local_dir = _class('ssh')->_prepare_path($local_dir);
$remote_dir = _class('ssh')->_prepare_path($remote_dir);
if ( ! _class('ssh')->_INIT_OK || ! $server_info || ! strlen($local_dir) || ! strlen($remote_dir)) {
Method show_site_title
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function show_site_title()
{
if (defined('SITE_ADVERT_NAME')) {
$title = SITE_ADVERT_NAME;
}
Method test_one_to_one
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function test_one_to_one()
{
if ($this->_need_skip_test(__FUNCTION__)) {
return;
}
Method scan_dir
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function scan_dir($start_dir, $FLAT_MODE = true, $include_pattern = '', $exclude_pattern = '')
{
if ( ! file_exists($start_dir)) {
return false;
}
Similar blocks of code found in 4 locations. Consider refactoring. Open
table($sql, [
'filter' => $filter,
'filter_params' => [
'user_id' => ['cond' => 'in', 'field' => 'u.id'],
'name' => 'like',
- 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 111.
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 div_box
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function div_box($name, $values = [], $selected = '', $extra = [])
{
if (is_array($name)) {
$extra = (array) $extra + $name;
$name = $extra['name'];
Method _preload_data
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _preload_data()
{
if ($this->_preload_complete) {
return true;
}
Method options_to_str
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function options_to_str(array $options, $is_request = true, $level = 1)
{
if ($level > $this->options_level_max) {
return null;
}
Method edit
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function edit()
{
$id = (int) ($_GET['id']);
if ( ! $id) {
return js_redirect(url('/@object'), false, 'Empty ID');
Method add_rule
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function add_rule()
{
$block_info = db()->query_fetch('SELECT * FROM ' . db('blocks') . ' WHERE id=' . (int) ($_GET['id']));
if (empty($block_info['id'])) {
return _e('No such block!');
Method _get_compiled_string
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _get_compiled_string($name, $replace = [], $params = [])
{
$compiled_string = null;
// TODO: add ability to use memcached or other fast cache-oriented storage instead of files => lower disk IO
$compiled_storage = 'files';
Method _validate_prepare
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _validate_prepare($validate_rules = [], $extra = [])
{
$form_global_validate = isset($this->_params['validate']) ? $this->_params['validate'] : (isset($this->_replace['validate']) ? $this->_replace['validate'] : []);
foreach ((array) $form_global_validate as $name => $rules) {
$this->_validate_rules[$name] = $rules;
Method list_keys
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function list_keys()
{
$do_real_work = true;
if ( ! $this->_driver_ok) {
$do_real_work = false;
Method query_fetch
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function query_fetch($sql, $use_cache = true, $assoc = true, $return_sql = false)
{
if ( ! strlen($sql)) {
return false;
}
Method connect
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function connect()
{
$dsn = 'mysql:host=' . $this->params['host'];
if ($this->params['port'] && $this->params['port'] != $this->DEF_PORT) {
$dsn .= ';port=' . $this->params['port'];
Method _load_oauth_providers
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function _load_oauth_providers()
{
$config = $this->_load_oauth_config();
if (isset($this->_providers_loaded)) {
return $this->_providers;
Method go
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function go($text = '')
{
$cur_page_md5 = md5($_GET['object'] . '%%' . $_GET['action'] . '%%' . $_GET['id']);
// Verify and send email
if ( ! empty($_POST['go'])) {
Method clear_pattern_child_process
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function clear_pattern_child_process()
{
if ( ! isset($_GET['id']) && (int) ($_GET['id'])) {
return t('Empty clear pattern ID');
}