NatLibFi/Skosmos

View on GitHub

Showing 1,049 of 1,049 total issues

Method generateConceptSearchQueryInner has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function generateConceptSearchQueryInner($term, $lang, $searchLang, $props, $unique, $filterGraph)
    {
        $valuesProp = $this->formatValues('?prop', $props);
        $textcond = $this->generateConceptSearchQueryCondition($term, $searchLang);

Severity: Minor
Found in src/model/sparql/GenericSparql.php - About 1 hr to fix

    Method transformTransitivePropertyResults has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function transformTransitivePropertyResults($result, $lang, $fallbacklang)
        {
            $ret = array();
            foreach ($result as $row) {
                if (!isset($row->object)) {
    Severity: Minor
    Found in src/model/sparql/GenericSparql.php - About 1 hr to fix

      Method sendFeedback has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function sendFeedback($request, $message, $messageSubject, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
          {
              $toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress();
              $messageSubject = "[" . $this->model->getConfig()->getServiceName() . "] " . $messageSubject;
              if ($fromVocab !== null && $fromVocab !== '') {
      Severity: Minor
      Found in src/controller/WebController.php - About 1 hr to fix

        Method generateChangeListQuery has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function generateChangeListQuery($prop, $lang, $offset, $limit = 200, $showDeprecated = false)
            {
                $fcl = $this->generateFromClause();
                $offset = ($offset) ? 'OFFSET ' . $offset : '';
        
        
        Severity: Minor
        Found in src/model/sparql/GenericSparql.php - About 1 hr to fix

          Method resolve has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function resolve(int $timeout): ?EasyRdf\Resource
              {
                  try {
                      // unregister the legacy "json" format as it causes problems with CONSTRUCT requests
                      EasyRdf\Format::unregister('json');
          Severity: Minor
          Found in src/model/resolver/WDQSResource.php - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                public function getConceptHierarchy($uri, $lang)
                {
                    $lang = $lang ? $lang : $this->getLang();
                    $fallback = count($this->config->getLanguageOrder($lang)) > 1 ? $this->config->getLanguageOrder($lang)[1] : $this->config->getDefaultLanguage();
                    $props = $this->config->getHierarchyProperty();
            Severity: Major
            Found in src/model/Vocabulary.php and 1 other location - About 1 hr to fix
            src/model/Vocabulary.php on lines 379..385

            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 110.

            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

                public function getConceptChildren($uri, $lang)
                {
                    $lang = $lang ? $lang : $this->getLang();
                    $fallback = count($this->config->getLanguageOrder($lang)) > 1 ? $this->config->getLanguageOrder($lang)[1] : $this->config->getDefaultLanguage();
                    $props = $this->config->getHierarchyProperty();
            Severity: Major
            Found in src/model/Vocabulary.php and 1 other location - About 1 hr to fix
            src/model/Vocabulary.php on lines 367..373

            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 110.

            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 getLabel has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getLabel($lang = '', $fallbackToUri = 'uri')
                {
                    if ($this->clang) {
                        $lang = $this->clang;
                    }
            Severity: Minor
            Found in src/model/ConceptPropertyValue.php - About 1 hr to fix

              Function transformConceptGroupsResults has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function transformConceptGroupsResults($result)
                  {
                      $ret = array();
                      foreach ($result as $row) {
                          if (!isset($row->group)) {
              Severity: Minor
              Found in src/model/sparql/GenericSparql.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

              Function transformAlphabeticalListResults has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function transformAlphabeticalListResults($results)
                  {
                      $ret = array();
              
                      foreach ($results as $row) {
              Severity: Minor
              Found in src/model/sparql/GenericSparql.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

              Function transformPropertyQueryResults has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function transformPropertyQueryResults($result, $lang)
                  {
                      $ret = array();
                      foreach ($result as $row) {
                          if (!isset($row->object)) {
              Severity: Minor
              Found in src/model/sparql/GenericSparql.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

              Function addExternalTriplesToGraph has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function addExternalTriplesToGraph($res, &$seen, $props = null)
                  {
                      if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) {
                          return;
                      }
              Severity: Minor
              Found in src/model/Concept.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

              Function getLabel has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getLabel()
                  {
                      foreach ($this->vocab->getConfig()->getLanguageOrder($this->clang) as $fallback) {
                          if ($this->resource->label($fallback) !== null) {
                              return $this->resource->label($fallback);
              Severity: Minor
              Found in src/model/Concept.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 disambiguateVocabulary has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function disambiguateVocabulary($vocabs, $uri, $preferredVocabId = null)
                  {
                      // if there is only one candidate vocabulary, return it
                      if (sizeof($vocabs) == 1) {
                          return $vocabs[0];
              Severity: Minor
              Found in src/model/Model.php - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                                this.hierarchy.push({ uri: concept.uri, label: concept.prefLabel, hasChildren: concept.hasChildren, children: [], isOpen: false, notation: concept.notation })
                Severity: Major
                Found in resource/js/tab-hierarchy.js and 1 other location - About 1 hr to fix
                resource/js/tab-hierarchy.js on lines 57..57

                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 62.

                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

                            this.hierarchy.push({ uri: c.uri, label: c.label, hasChildren: c.hasChildren, children: [], isOpen: false, notation: c.notation })
                Severity: Major
                Found in resource/js/tab-hierarchy.js and 1 other location - About 1 hr to fix
                resource/js/tab-hierarchy.js on lines 97..97

                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 62.

                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 3 locations. Consider refactoring.
                Open

                      fetch('rest/v1/' + window.SKOSMOS.vocab + '/index/?lang=' + window.SKOSMOS.content_lang)
                        .then(data => {
                          return data.json()
                        })
                        .then(data => {
                Severity: Major
                Found in resource/js/tab-alpha.js and 2 other locations - About 1 hr to fix
                resource/js/tab-hierarchy.js on lines 47..62
                resource/js/term-counts.js 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 62.

                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 3 locations. Consider refactoring.
                Open

                      fetch('rest/v1/' + window.SKOSMOS.vocab + '/labelStatistics?lang=' + window.SKOSMOS.lang)
                        .then(data => {
                          return data.json()
                        })
                        .then(data => {
                Severity: Major
                Found in resource/js/term-counts.js and 2 other locations - About 1 hr to fix
                resource/js/tab-alpha.js on lines 51..60
                resource/js/tab-hierarchy.js on lines 47..62

                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 62.

                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 3 locations. Consider refactoring.
                Open

                      fetch('rest/v1/' + window.SKOSMOS.vocab + '/topConcepts/?lang=' + window.SKOSMOS.content_lang)
                        .then(data => {
                          return data.json()
                        })
                        .then(data => {
                Severity: Major
                Found in resource/js/tab-hierarchy.js and 2 other locations - About 1 hr to fix
                resource/js/tab-alpha.js on lines 51..60
                resource/js/term-counts.js 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 62.

                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 getDataURLs has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getDataURLs()
                    {
                        $ret = array();
                        $urls = $this->resource->allResources("void:dataDump");
                        foreach ($urls as $url) {
                Severity: Minor
                Found in src/model/VocabularyConfig.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language