Showing 1,089 of 1,089 total issues
Method populate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
{
$_source_file_path = str_replace(':', '.', $_template->source->filepath);
$_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null;
$_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
Method compile
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function compile($args, $compiler, $parameter, $tag, $function)
{
if (!isset($tag[5]) || substr($tag, -5) != 'close') {
// opening tag of block plugin
// check and get attributes
Method compile
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function compile($args, $compiler, $parameter, $tag)
{
// This tag does create output
$compiler->has_output = true;
// check and get attributes
Method getAllIdleWorkers
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAllIdleWorkers($interval=600) {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("
SELECT w.account_id AS account_id, w.id AS id, w.username AS username
FROM
Method createDebitRecord
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createDebitRecord($account_id, $coin_address, $amount, $type) {
// Calculate and deduct txfee from amount
$type == 'Debit_MP' ? $txfee = $this->config['txfee_manual'] : $txfee = $this->config['txfee_auto'];
$amount = $amount - $txfee;
// Add Debit record
Method processDefListItems
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processDefListItems($list_str) {
#
# Process the contents of a single definition list, splitting it
# into individual term and definition list items.
#
Method getTemplateVars
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
{
if (isset($varname)) {
$_var = $this->getVariable($varname, $_ptr, $search_parents, false);
if (is_object($_var)) {
Method compile
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function compile($args, $compiler)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
Method yy_r154
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function yy_r154(){
if (!$this->security || $this->smarty->security_policy->isTrustedPhpFunction($this->yystack[$this->yyidx + -3]->minor, $this->compiler)) {
if (strcasecmp($this->yystack[$this->yyidx + -3]->minor,'isset') === 0 || strcasecmp($this->yystack[$this->yyidx + -3]->minor,'empty') === 0 || strcasecmp($this->yystack[$this->yyidx + -3]->minor,'array') === 0 || is_callable($this->yystack[$this->yyidx + -3]->minor)) {
$func_name = strtolower($this->yystack[$this->yyidx + -3]->minor);
if ($func_name == 'isset') {
Method getUserEstimates
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getUserEstimates($value1, $value2, $dDonate, $bNoFees, $ppsvalue=0) {
$this->debug->append("STA " . __METHOD__, 4);
if ($this->config['payout_system'] != 'pps') {
if (@$value1['valid'] > 0 && @$value2['valid'] > 0) {
$this->config['reward_type'] == 'fixed' ? $reward = $this->config['reward'] : $reward = $this->block->getAverageAmount();
Method sendNotification
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendNotification($account_id, $strType, $aMailData) {
// Check if we notified for this event already
if ( $this->isNotified($aMailData) ) {
$this->setErrorMessage('A notification for this event has been sent already');
return false;
Method flushQueue
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function flushQueue(Swift_Transport $transport, &$failedRecipients = null)
{
$directoryIterator = new DirectoryIterator($this->_path);
/* Start the transport only if there are queued files to send */
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($_double_encode) {
return 'htmlspecialchars('
. $params[0] .', ENT_QUOTES, '
. var_export($char_set, true) . ', '
. var_export($double_encode, true) . ')';
- 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 106.
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 ($_double_encode) {
// php >=5.2.3 - go native
return 'htmlentities('
. $params[0] .', ENT_QUOTES, '
. var_export($char_set, true) . ', '
- 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 106.
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 addAutoloadFilters
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function addAutoloadFilters($filters, $type=null)
{
if ($type !== null) {
if (!empty($this->autoload_filters[$type])) {
$this->autoload_filters[$type] = array_merge($this->autoload_filters[$type], (array) $filters);
- 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 isTrustedPHPDir
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function isTrustedPHPDir($filepath)
{
if (empty($this->trusted_dir)) {
throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)");
}
- 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 normalizePath
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function normalizePath($_path, $ds=true)
{
if ($ds) {
// don't we all just love windows?
$_path = str_replace('\\', '/', $_path);
- 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 isTokenValid
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function isTokenValid($account_id, $token, $type, $checkTimeExplicitly=false) {
if (!is_int($account_id) || !is_int($type)) {
$this->setErrorMessage("Invalid token");
return 0;
}
- 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 getReaderFor
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getReaderFor($charset)
{
$charset = trim(strtolower($charset));
foreach (self::$_map as $pattern => $spec) {
$re = '/^' . $pattern . '$/D';
- 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 si2bin
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function si2bin($si, $bits = 32)
{
$bin = null;
if ($si >= -pow(2, $bits - 1) && ($si <= pow(2, $bits - 1))) {
// positive or zero
- 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"