NatLibFi/Skosmos

View on GitHub

Showing 1,049 of 1,049 total issues

Function searchConcepts has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function searchConcepts($params)
    {
        // don't even try to search for empty prefix if no other search criteria (group or parent concept) has been set
        if (($params->getSearchTerm() === "" || !preg_match('/[^*]/', $params->getSearchTerm())) && !$params->getGroupLimit() && !$params->getParentLimit()) {
            return array();
Severity: Minor
Found in src/model/Model.php - About 2 hrs 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 getCrumbs has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function getCrumbs($bTresult, $uri, $path = null)
    {
        $crumbs = array();
        if (!isset($path)) {
            $path = array();
Severity: Minor
Found in src/model/Vocabulary.php - About 2 hrs 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 startTermCountsApp has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function startTermCountsApp () {
  const termCountsApp = Vue.createApp({
    data () {
      return {
        languages: []
Severity: Major
Found in resource/js/term-counts.js - About 2 hrs to fix

    Method transformConceptSearchResult has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function transformConceptSearchResult($row, $vocabs, $fields)
        {
            $hit = array();
            $hit['uri'] = $row->s->getUri();
    
    
    Severity: Major
    Found in src/model/sparql/GenericSparql.php - About 2 hrs to fix

      Method invokeVocabularySearch has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function invokeVocabularySearch($request)
          {
              $template = $this->twig->load('vocab-search.twig');
              $this->model->setLocale($request->getLang());
              $vocab = $request->getVocab();
      Severity: Major
      Found in src/controller/WebController.php - About 2 hrs to fix

        Method transformParentListResults has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function transformParentListResults($result, $lang)
            {
                $ret = array();
                foreach ($result as $row) {
                    if (!isset($row->broad)) {
        Severity: Major
        Found in src/model/sparql/GenericSparql.php - About 2 hrs to fix

          Method hierarchy has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function hierarchy($request)
              {
                  if ($this->notModified($request->getVocab())) {
                      return null;
                  }
          Severity: Major
          Found in src/controller/RestController.php - About 2 hrs to fix

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

                public function related($request)
                {
                    if ($this->notModified($request->getVocab())) {
                        return null;
                    }
            Severity: Major
            Found in src/controller/RestController.php and 2 other locations - About 2 hrs to fix
            src/controller/RestController.php on lines 869..880
            src/controller/RestController.php on lines 905..916

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

            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

                public function broader($request)
                {
                    if ($this->notModified($request->getVocab())) {
                        return null;
                    }
            Severity: Major
            Found in src/controller/RestController.php and 2 other locations - About 2 hrs to fix
            src/controller/RestController.php on lines 905..916
            src/controller/RestController.php on lines 1100..1111

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

            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

                public function narrower($request)
                {
                    if ($this->notModified($request->getVocab())) {
                        return null;
                    }
            Severity: Major
            Found in src/controller/RestController.php and 2 other locations - About 2 hrs to fix
            src/controller/RestController.php on lines 869..880
            src/controller/RestController.php on lines 1100..1111

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

            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

            Function transformConceptGroupContentsResults has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                private function transformConceptGroupContentsResults($result, $lang)
                {
                    $ret = array();
                    $values = array();
                    foreach ($result as $row) {
            Severity: Minor
            Found in src/model/sparql/GenericSparql.php - About 2 hrs 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 getDataURLs has a Cognitive Complexity of 17 (exceeds 5 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 2 hrs 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 findLookupHits has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function findLookupHits($results, $label, $lang)
                {
                    $hits = array();
                    // case 1: exact match on preferred label
                    foreach ($results as $res) {
            Severity: Major
            Found in src/controller/RestController.php - About 2 hrs to fix

              Method invokeGlobalSearch has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function invokeGlobalSearch($request)
                  {
                      $lang = $request->getLang();
                      $template = $this->twig->load('global-search.twig');
                      $this->model->setLocale($request->getLang());
              Severity: Major
              Found in src/controller/WebController.php - About 2 hrs to fix

                Function generateConceptSearchQuery has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function generateConceptSearchQuery($fields, $unique, $params, $showDeprecated = false)
                    {
                        $vocabs = $params->getVocabs();
                        $gcl = $this->graphClause;
                        $fcl = empty($vocabs) ? '' : $this->generateFromClause($vocabs);
                Severity: Minor
                Found in src/model/sparql/GenericSparql.php - About 2 hrs 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 transformChangeListResults has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function transformChangeListResults($result)
                    {
                        $ret = array();
                        foreach ($result as $row) {
                            $concept = array('uri' => $row->concept->getURI());
                Severity: Minor
                Found in src/model/sparql/GenericSparql.php - About 2 hrs 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 filterPlugins has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function filterPlugins($type, $raw = false)
                    {
                        $plugins = $this->getPlugins();
                        $plugins = $this->sortPlugins($plugins);
                        $ret = array();
                Severity: Minor
                Found in src/model/PluginRegister.php - About 2 hrs 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 loadConceptHierarchy has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    loadConceptHierarchy () {
                      this.loadingHierarchy = true
                      fetch('rest/v1/' + window.SKOSMOS.vocab + '/hierarchy/?uri=' + window.SKOSMOS.uri + '&lang=' + window.SKOSMOS.content_lang)
                        .then(data => {
                          return data.json()
                Severity: Major
                Found in resource/js/tab-hierarchy.js - About 2 hrs to fix

                  Function removeDuplicatePropertyValues has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function removeDuplicatePropertyValues($ret, $duplicates)
                      {
                          $propertyValues = array();
                  
                          foreach ($ret as $prop) {
                  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 generateAlphabeticalListQuery has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function generateAlphabeticalListQuery($letter, $lang, $limit = null, $offset = null, $classes = null, $showDeprecated = false, $qualifier = null)
                      {
                          if ($letter == '*' || $letter == '0-9' || $letter == '!*') {
                              // text index cannot support special character queries, use the generic implementation for these
                              return parent::generateAlphabeticalListQuery($letter, $lang, $limit, $offset, $classes, $showDeprecated, $qualifier);
                  Severity: Minor
                  Found in src/model/sparql/JenaTextSparql.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language