Showing 371 of 371 total issues
File trash.php
has 304 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
Copyright 2020 Guillaume Boudreau
This file is part of Greyhole.
Function loadStatusQueue
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
function loadStatusQueue() {
var $table = $('#queue');
var $loading_row = $table.find('.loading');
$loading_row.show();
$.ajax({
- 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 create_file_copies
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function create_file_copies($source_file, &$metafiles) {
$copy_results = [];
$copy_source = is_link($source_file) ? readlink($source_file) : $source_file;
$source_size = gh_filesize($copy_source);
File CommandLineHelper.php
has 296 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
Copyright 2009-2020 Guillaume Boudreau
This file is part of Greyhole.
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (unix_extensions_config === 'yes' && allow_insecure_wide_links_config === 'no') {
$('[name=' + $.escapeSelector('smb.conf:[global]unix_extensions') + ']').parent('label').removeClass('btn-outline-primary').addClass('btn-outline-danger');
$('[name=' + $.escapeSelector('smb.conf:[global]allow_insecure_wide_links') + ']').parent('label').removeClass('btn-outline-primary').addClass('btn-outline-danger');
} else {
- 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 97.
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
} else {
$('[name=' + $.escapeSelector('smb.conf:[global]unix_extensions') + ']').parent('label').removeClass('btn-outline-danger').addClass('btn-outline-primary');
$('[name=' + $.escapeSelector('smb.conf:[global]allow_insecure_wide_links') + ']').parent('label').removeClass('btn-outline-danger').addClass('btn-outline-primary');
}
- 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 97.
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 run
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function run() {
Log::setAction(ACTION_INITIALIZE);
Metastores::choose_metastores_backups();
Log::setAction(ACTION_MOVE);
- 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 is_pool_drive
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static function is_pool_drive($sp_drive) {
global $going_drive;
if (isset($going_drive) && $sp_drive == $going_drive) {
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"
Further reading
Method get_email_body
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_email_body($include_trash_size) {
if (empty($this->end)) {
$this->end = time();
}
Method _log
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function _log($local_log_level, $text, $event_code) {
if (self::$action == 'test-config' || self::$action == ACTION_CP) {
$greyhole_log_file = NULL;
$use_syslog = FALSE;
if (self::$action == ACTION_CP && $local_log_level > self::$level) {
Function drawTreeMapDiskUsage
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
function drawTreeMapDiskUsage(ctx, du_stats) {
let dataset = [];
let paths = [];
let max = 0, min = null;
Function ajax_value_changed
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
function ajax_value_changed($el, name, value, success) {
// console.log(name + " = " + value);
$.ajax({
type: 'POST',
url: './?ajax=config',
- 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 run
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run() {
Log::setAction(ACTION_INITIALIZE);
Metastores::choose_metastores_backups();
Log::setAction(ACTION_MOVE);
Method get_metafiles_for_file
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get_metafiles_for_file($share, $path, $filename=NULL, $load_nok_metafiles=FALSE, $quiet=FALSE, $check_symlink=TRUE) {
if (!$quiet) {
Log::debug("Loading metafiles for " . clean_dir($share . (!empty($path) ? "/$path" : "") . "/$filename") . ' ...');
}
$metafiles_data_file = static::get_metafile_data_filename($share, $path, $filename);
Function close_all_tasks
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function close_all_tasks($tasks) {
$q = "SELECT COUNT(*) FROM tasks WHERE complete = 'no'";
$has_incomplete_tasks = (int) DB::getFirstValue($q);
$q = "SELECT COUNT(*) FROM tasks WHERE complete = 'written'";
- 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 xcopy
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function xcopy($src,$dest) {
// recursive copy
if (!is_dir($dest)) {
mkdir($dest);
}
- 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 loadStatusBalanceReport
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
function loadStatusBalanceReport() {
let $container = $('#balance_groups');
$.ajax({
type: 'POST',
url: './?ajax=get_status_balance_report',
Function execute
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
Log::info("Starting available space balancing");
// Start with shares that have sticky files, so that subsequent shares will be used to try to balance what moving files into stick_into drives could debalance...
// Then start with the shares for which we keep the most # copies;
- 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 run
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run() {
ConfigHelper::parse();
DB::connect();
Log::setAction(ACTION_INITIALIZE);
Metastores::choose_metastores_backups();
Method gh_mkdir
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function gh_mkdir($directory, $original_directory, $dir_permissions = NULL) {
$directory = clean_dir($directory);
$original_directory = clean_dir($original_directory);
if (is_dir($directory)) {
if (empty($dir_permissions)) {