Showing 8,683 of 8,684 total issues
Function body_content
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function body_content()
{
$dbc = $this->connection;
$dbc->selectDB($this->config->get('OP_DB'));
$transDB = $this->config->get('TRANS_DB') . $dbc->sep();
- 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 getTime
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
private function getTime($string)
{
$regex = '/(\d{1,2}\s{0,2}(?:am|pm|(?::\d\d)){0,1}\s{0,2}(?:am|pm){0,1})(?:\s{0,2}(?:-|to|till|until)\s{0,2}(\d{1,2}\s{0,2}(?:am|pm|(?::\d\d)){0,1}\s{0,2}(?:am|pm){0,1}))?/i';
$ret = false;
if (preg_match($regex, $string, $matches)) {
- 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 sort
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function sort(array $rowset)
{
$tax = false;
$discount = false;
$total = 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
Function post_printFY_handler
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
function post_printFY_handler()
{
global $FANNIE_PLUGIN_SETTINGS, $FANNIE_OP_DB;
$dbc = FannieDB::get($FANNIE_PLUGIN_SETTINGS['GiveUsMoneyDB']);
if (!class_exists('FPDF')) {
- 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 process
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function process($filename)
{
$fp = fopen($filename, 'r');
$currentOrder = array('id' => false, 'total' => 0, 'tax' => 0, 'card_no' => 11, 'memType'=>0, 'tdate' => '');
$trans_id = 1;
- 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 pushTable
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
static public function pushTable($table,$db='op',$truncate=self::TRUNCATE_DESTINATION,$includeOffline=false)
{
$config = \FannieConfig::factory();
$op_db = $config->get('OP_DB');
$trans_db = $config->get('TRANS_DB');
- 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 CreateDynamic
has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring. Open
private object CreateDynamic(JsonReader reader, JsonDynamicContract contract, JsonProperty member, string id)
{
IDynamicMetaObjectProvider newObject;
if (!contract.IsInstantiable)
- 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 PrehLib.php
has 405 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2001, 2004 Wedge Community Co-op
File FpdfEditorPage.php
has 405 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2015 Whole Foods Co-op
File WFC_Hybrid_Single.php
has 405 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
if (!class_exists('FpdfWithBarcode')) {
include(dirname(__FILE__) . '/../FpdfWithBarcode.php');
}
if (!class_exists('FpdfLib')) {
Method get_id_view
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_id_view()
{
$id = trim($this->id);
if (!preg_match('/^\d+-\d+$/', $id)) {
return '<div class="alert alert-danger">Order Number should be two numbers separated by a dash</div>
Method get_id_pdf_handler
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_id_pdf_handler()
{
if (!class_exists('FPDF')) {
include(__DIR__ . '/../../../src/fpdf/fpdf.php');
define('FPDF_FONTPATH','font/');
Method get_view
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_view()
{
$storeID = Store::getIdByIp();
$storeID=1;
$catP = $this->connection->prepare("SELECT deliCategoryID, name, salesCode FROM DeliCategories WHERE storeID=? ORDER BY seq, name");
Method get_orderID_customer_handler
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_orderID_customer_handler()
{
$dbc = $this->connection;
$dbc->selectDB($this->config->get('OP_DB'));
$TRANS = $this->config->get('TRANS_DB') . $dbc->sep();
Method getCustomerNonForm
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getCustomerNonForm($orderID)
{
global $FANNIE_OP_DB, $TRANS, $FANNIE_TRANS_DB;
$dbc = FannieDB::get($FANNIE_OP_DB);
Method get_id_view
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_id_view()
{
$dbc = FannieDB::get($this->config->get('OP_DB'));
$ret = '<div id="myform" style="background-color: white;">
<form method="post">
File EditItemsFromSearch.php
has 405 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*******************************************************************************
Copyright 2013 Whole Foods Community Co-op
Method form_content
has 142 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function form_content()
{
$storepicker = FormLib::storePicker();
$store = FormLib::get('store');
$datepicker = FormLib::date_range_picker();
Method post_u_view
has 142 lines of code (exceeds 25 allowed). Consider refactoring. Open
function post_u_view()
{
global $FANNIE_OP_DB, $FANNIE_URL, $FANNIE_ARCHIVE_DB;
$dbc = FannieDB::get($FANNIE_OP_DB);
$this->addScript($FANNIE_URL.'src/javascript/tablesorter/jquery.tablesorter.js');
Identical blocks of code found in 2 locations. Consider refactoring. Open
foreach($hbKeys as $hbKey) {
$hbTarget = "$hbPrefix" . ++$hbNumber;
if (isset($hbLongMessage["$hbKey"]) && $hbLongMessage["$hbKey"] != "") {
$anyMore = $hbMore;
$onClick = " onclick=\"$('#{$hbTarget}').toggle();return false;\" ";
- 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 197.
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