Showing 53 of 53 total issues
File XLSXWriter.php
has 1038 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace luya\yii\helpers;
use ZipArchive;
Function numberFormatStandardized
has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring. Open
private static function numberFormatStandardized($num_format)
{
if ($num_format == 'money') {
$num_format = 'dollar';
}
- 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 styleFontIndexes
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
protected function styleFontIndexes()
{
static $border_allowed = ['left', 'right', 'top', 'bottom'];
static $border_style_allowed = [
'thin',
- 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
XLSXWriter
has 41 functions (exceeds 20 allowed). Consider refactoring. Open
class XLSXWriter
{
//https://www.ecma-international.org/publications/standards/Ecma-376.htm
//http://officeopenxml.com/SSstyles.php
//------------------------------------------------------------------
Function generateContentArray
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
protected static function generateContentArray($contentRows, array $keys, $generateHeader = true, $options = [])
{
if (is_scalar($contentRows)) {
throw new Exception("Content must be either an array, object or traversable.");
}
- 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 writeStylesXML
has 123 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function writeStylesXML()
{
$r = $this->styleFontIndexes();
$fills = $r['fills'];
$fonts = $r['fonts'];
Function writeStylesXML
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
protected function writeStylesXML()
{
$r = $this->styleFontIndexes();
$fills = $r['fills'];
$fonts = $r['fonts'];
- 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 styleFontIndexes
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function styleFontIndexes()
{
static $border_allowed = ['left', 'right', 'top', 'bottom'];
static $border_style_allowed = [
'thin',
Method initializeSheet
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function initializeSheet(
$sheet_name,
$col_widths = [],
$auto_filter = false,
$freeze_rows = false,
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (isset($style['border-color']) && is_string($style['border-color']) && $style['border-color'][0] == '#') {
$v = substr($style['border-color'], 1, 6);
$v = strlen($v) == 3 ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v;// expand cf0 => ccff00
$border_value['color'] = "FF" . strtoupper($v);
}
- 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 156.
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 (isset($style['color']) && is_string($style['color']) && $style['color'][0] == '#') {
$v = substr($style['color'], 1, 6);
$v = strlen($v) == 3 ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v;// expand cf0 => ccff00
$font['color'] = "FF" . strtoupper($v);
}
- 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 156.
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 csvFromResource
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function csvFromResource($resource, array $options = []): array
{
if (!is_resource($resource)) {
throw new \InvalidArgumentException("The provided resource is not a valid resource.");
}
- 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 highlightWord
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function highlightWord($content, $word, $markup = '<b>%s</b>')
{
$transliterateContent = Inflector::transliterate($content);
$highlights = [];
- 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 convert_date_time
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function convert_date_time($date_input) //thanks to Excel::Writer::XLSX::Worksheet.pm (perl)
{
$days = 0; # Number of days since epoch
$seconds = 0; # Time expressed as fraction of 24h hours in seconds
$year = $month = $day = 0;
Method numberFormatStandardized
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function numberFormatStandardized($num_format)
{
if ($num_format == 'money') {
$num_format = 'dollar';
}
Function writeCell
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function writeCell(
XLSXWriter_BuffererWriter &$file,
$row_number,
$column_number,
$value,
- 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 generateContentArray
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function generateContentArray($contentRows, array $keys, $generateHeader = true, $options = [])
{
if (is_scalar($contentRows)) {
throw new Exception("Content must be either an array, object or traversable.");
}
Function unlink
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function unlink($file)
{
// no errors should be thrown, return false instead.
try {
if (parent::unlink($file)) {
- 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 writeToFile
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function writeToFile($filename)
{
foreach ($this->sheets as $sheet_name => $sheet) {
$this->finalizeSheet($sheet_name);//making sure all footers have been written
}
Method writeSheetRow
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function writeSheetRow($sheet_name, array $row, $row_options = null)
{
if (empty($sheet_name)) {
return;
}