Showing 50 of 50 total issues
Function generate
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function generate()
{
$ok = false;
$_f = $this->getDbFilepath();
$i18n = I18n::getInstance();
- 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 parse
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse(Twig_Token $token)
{
$i18n = I18n::getInstance();
$lineno = $token->getLine();
$stream = $this->parser->getStream();
Function hightlight_css
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
hightlight_css: function(code) {
var comments = []; // store comments
var keywords = 'background-color background-image background-position ' +
Method generate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate($from_file, \I18n\I18n $i18n)
{
$default = $i18n->getLoader()->getOption('default_language', 'en');
$all_lang_strings = $headers = array();
Function buildFootNotes
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildFootNotes(){
var bl_sup = $('<sup />'),
bl_a_hdlr = $('<a />', { 'class':'footnote_link', 'title':'See footnote' }),
bl_a_back = $('<a />', { 'class':'footnote_link', 'title':'Back in content' }).html('↩'),
bl_note = $('<li />');
Identical blocks of code found in 3 locations. Consider refactoring. Open
function _getSecuredRealPath($path, $depth_from_root = 1)
{
$ds = DIRECTORY_SEPARATOR;
$parts = explode($ds, realpath('.'));
for ($i=0; $i<=$depth_from_root; $i++) array_pop($parts);
- 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
Identical blocks of code found in 3 locations. Consider refactoring. Open
function _getSecuredRealPath($path, $depth_from_root = 1)
{
$ds = DIRECTORY_SEPARATOR;
$parts = explode($ds, realpath('.'));
for ($i=0; $i<=$depth_from_root; $i++) array_pop($parts);
- 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
Identical blocks of code found in 3 locations. Consider refactoring. Open
function _getSecuredRealPath($path, $depth_from_root = 1)
{
$ds = DIRECTORY_SEPARATOR;
$parts = explode($ds, realpath('.'));
for ($i=0; $i<=$depth_from_root; $i++) array_pop($parts);
- 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
Method generate
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate()
{
$ok = false;
$_f = $this->getDbFilepath();
$i18n = I18n::getInstance();
Method init
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function init(LoaderInterface $loader, $lang = null, $timezone = null)
{
$this->setLoader($loader);
if (is_null($lang)) {
$lang = substr(Locale::getDefault(), 0, 2);
Function _getOrigin
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function _getOrigin()
{
$ch = curl_init(self::IANA_LANGUAGE_SUBTAG_REGISTRY);
if ($ch) {
$tmpfname = tempnam("/tmp", "ianadb.txt");
- 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 findLanguageDBFile
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function findLanguageDBFile($db_filename = null, $db_directory = null)
{
if (empty($db_filename)) {
$db_filename = $this->buildLanguageDBFileName();
}
- 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 __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Twig_Node_Expression_Array $choices,
Twig_Node_Expression_Constant $counter,
Twig_Node_Expression_Array $params,
Twig_Node_Expression_Constant $lang,
$lineno, $tag = null
Similar blocks of code found in 2 locations. Consider refactoring. Open
code = code
//replace attributes
.replace(/\s+([a-zA-Z\-]{0,15})\=\"([-a-z0-9_ \/\.\#\:\=\;]{0,49})\"/gi,' <span class="atn">$1</span>=<span class="atv">"$2"</span>')
//replace open tags
.replace(/(<)(\w{0,15})(\s+|>|>)/gi,'$1<span class="tag">$2</span>$3')
- 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 49.
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
code = code
//replace keywords
.replace(/(var|function|typeof|new|return|if|for|in|while|break|do|continue|case|switch)([^a-z0-9\$_])/gi,'<span class="kwd">$1</span>$2')
//replace keywords
.replace(/(\{|\}|\]|\[|\|)/gi,'<span class="kwd">$1</span>')
- 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 49.
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 __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Twig_NodeInterface $body,
Twig_Node_Expression_Array $params,
Twig_Node_Expression_Constant $lang,
$lineno, $tag = null
Function parseStringMetadata
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function parseStringMetadata($str)
{
$info = array();
if (0!==preg_match('~^\[([^\]]+)\]~i', $str, $matches)) {
$str = str_replace($matches[0], '', $str);
- 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 loadClass
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function loadClass($className)
{
if ($filePath = $this->resolveFileName($className)) {
if ($this->getFailureFlag() & self::FAIL_GRACEFULLY) {
if ($this->classFileExists($filePath)) {
- 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 init
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function init(LoaderInterface $loader, $lang = null, $timezone = null)
{
$this->setLoader($loader);
if (is_null($lang)) {
$lang = substr(Locale::getDefault(), 0, 2);
- 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 translate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function translate($index, array $args = null, $lang = null)
{
$_this = self::getInstance();
if (!is_null($lang)) {
$original_lang = $_this->getLanguage();
- 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"