atelierspierrot/internationalization

View on GitHub

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();
Severity: Minor
Found in src/I18n/Generator.php - About 1 hr to fix

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();
Severity: Minor
Found in src/I18n/Twig/TranslateTokenParser.php - About 1 hr to fix

    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 ' +
    Severity: Minor
    Found in demo/assets/js/highlight.js - About 1 hr to fix

      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();
      
      
      Severity: Minor
      Found in src/I18n/Generator/Csv.php - About 1 hr to fix

        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('&#8617;'),
                bl_note = $('<li />');
        Severity: Minor
        Found in demo/assets/scripts.js - About 1 hr to fix

          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);
          Severity: Major
          Found in demo/twig.php and 2 other locations - About 1 hr to fix
          demo/iana.php on lines 28..34
          demo/index.php on lines 28..34

          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

          Further Reading

          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);
          Severity: Major
          Found in demo/index.php and 2 other locations - About 1 hr to fix
          demo/iana.php on lines 28..34
          demo/twig.php on lines 28..34

          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

          Further Reading

          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);
          Severity: Major
          Found in demo/iana.php and 2 other locations - About 1 hr to fix
          demo/index.php on lines 28..34
          demo/twig.php on lines 28..34

          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

          Further Reading

          Method generate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function generate()
              {
                  $ok     = false;
                  $_f     = $this->getDbFilepath();
                  $i18n   = I18n::getInstance();
          Severity: Minor
          Found in src/I18n/Generator.php - About 1 hr to fix

            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);
            Severity: Minor
            Found in src/I18n/I18n.php - About 1 hr to fix

              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");
              Severity: Minor
              Found in src/I18n/Iana.php - About 55 mins to fix

              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();
                      }
              Severity: Minor
              Found in src/I18n/Loader.php - About 55 mins to fix

              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
              Severity: Minor
              Found in src/I18n/Twig/PluralizeNode.php - About 45 mins to fix

                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(/(&lt;)(\w{0,15})(\s+|&gt;|>)/gi,'$1<span class="tag">$2</span>$3')
                Severity: Minor
                Found in demo/assets/js/highlight.js and 1 other location - About 40 mins to fix
                demo/assets/js/highlight.js on lines 110..119

                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

                Further Reading

                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>')
                Severity: Minor
                Found in demo/assets/js/highlight.js and 1 other location - About 40 mins to fix
                demo/assets/js/highlight.js on lines 256..264

                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

                Further Reading

                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
                Severity: Minor
                Found in src/I18n/Twig/TranslateNode.php - About 35 mins to fix

                  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);
                  Severity: Minor
                  Found in src/I18n/I18n.php - About 35 mins to fix

                  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);
                  Severity: Minor
                  Found in src/I18n/I18n.php - About 35 mins to fix

                  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)) {
                  Severity: Minor
                  Found in src/SplClassLoader.php - About 35 mins to fix

                  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();
                  Severity: Minor
                  Found in src/I18n/I18n.php - About 35 mins to fix

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language