NatLibFi/Skosmos

View on GitHub

Showing 1,049 of 1,049 total issues

Function linkUrlFilter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function linkUrlFilter($uri, $vocab, $lang, $type = 'page', $clang = null, $term = null)
    {
        // $vocab can either be null, a vocabulary id (string) or a Vocabulary object
        if ($vocab === null) {
            return $uri;
Severity: Minor
Found in src/controller/LinkUrlExtension.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 setParameterizedPlugins has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function setParameterizedPlugins(): void
    {
        $this->pluginParameters = array();

        $vocabularyPlugins = $this->resource->getResource('skosmos:vocabularyPlugins');
Severity: Minor
Found in src/model/VocabularyConfig.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 changedConcepts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function changedConcepts($request, $prop, $offset, $limit)
    {
        $changeList = $request->getVocab()->getChangeList($prop, $request->getLang(), $offset, $limit);

        $simpleChangeList = array();
Severity: Minor
Found in src/controller/RestController.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 transformQueryConceptSchemesResults has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function transformQueryConceptSchemesResults($result)
    {
        $ret = array();
        foreach ($result as $row) {
            $conceptscheme = array();
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 getVocabularies has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function getVocabularies()
    {
        if ($this->allVocabularies === null) { // initialize cache
            $vocs = $this->globalConfig->getGraph()->allOfType('skosmos:Vocabulary');
            $this->allVocabularies = $this->createDataObjects("Vocabulary", $vocs);
Severity: Minor
Found in src/model/Model.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 getCollectionMembers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function getCollectionMembers($coll, $narrowers)
    {
        $membersArray = array();
        if ($coll->label()) {
            $collLabel = $coll->label()->getValue($this->clang) ? $coll->label($this->clang) : $coll->label();
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 mappings has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function mappings(Request $request)
    {
        $this->model->setLocale($request->getLang());
        $vocab = $request->getVocab();
        if ($this->notModified($vocab)) {
Severity: Minor
Found in src/controller/RestController.php - About 1 hr to fix

    Method label has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function label($request)
        {
            if (!$request->getUri()) {
                return $this->returnError(400, "Bad Request", "uri parameter missing");
            }
    Severity: Minor
    Found in src/controller/RestController.php - About 1 hr to fix

      Method transformChangeListResults has 27 lines of code (exceeds 25 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 1 hr to fix

        Method sortValues has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function sortValues()
            {
                # TODO: sort by URI as last resort
                # Note that getLabel() returns URIs in case of no label and may return a prefixed value which affects sorting
                if (!empty($this->values)) {
        Severity: Minor
        Found in src/model/ConceptProperty.php - About 1 hr to fix

          Method generateChildQuery has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function generateChildQuery($uri, $lang, $fallback, $props)
              {
                  $uri = is_array($uri) ? $uri[0] : $uri;
                  $fcl = $this->generateFromClause();
                  $propertyClause = implode('|', $props);
          Severity: Minor
          Found in src/model/sparql/GenericSparql.php - About 1 hr to fix

            Method generateTransitivePropertyQuery has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function generateTransitivePropertyQuery($uri, $props, $lang, $limit, $anylang)
                {
                    $uri = is_array($uri) ? $uri[0] : $uri;
                    $fcl = $this->generateFromClause();
                    $propertyClause = implode('|', $props);
            Severity: Minor
            Found in src/model/sparql/GenericSparql.php - About 1 hr to fix

              Method changedConcepts has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function changedConcepts($request, $prop, $offset, $limit)
                  {
                      $changeList = $request->getVocab()->getChangeList($prop, $request->getLang(), $offset, $limit);
              
                      $simpleChangeList = array();
              Severity: Minor
              Found in src/controller/RestController.php - About 1 hr to fix

                Function transformCountConceptsResults has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function transformCountConceptsResults($result, $lang)
                    {
                        $ret = array();
                        foreach ($result as $row) {
                            if (!isset($row->type)) {
                Severity: Minor
                Found in src/model/sparql/GenericSparql.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 transformTransitivePropertyResults has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private function transformTransitivePropertyResults($uri, $lang, $objects, $tpropname, $tpropuri, $dpropname, $dpropuri)
                Severity: Major
                Found in src/controller/RestController.php - About 50 mins to fix

                  Method generateAlphabeticalListQuery has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      protected function generateAlphabeticalListQuery($letter, $lang, $limit, $offset, $classes, $showDeprecated = false, $qualifier = null)
                  Severity: Major
                  Found in src/model/sparql/GenericSparql.php - About 50 mins to fix

                    Method queryConceptsAlphabetical has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function queryConceptsAlphabetical($letter, $lang, $limit = null, $offset = null, $classes = null, $showDeprecated = false, $qualifier = null)
                    Severity: Major
                    Found in src/model/sparql/GenericSparql.php - About 50 mins to fix

                      Method sendFeedback has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public function sendFeedback($request, $message, $messageSubject, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
                      Severity: Major
                      Found in src/controller/WebController.php - About 50 mins to fix

                        Method generateAlphabeticalListQuery has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public function generateAlphabeticalListQuery($letter, $lang, $limit = null, $offset = null, $classes = null, $showDeprecated = false, $qualifier = null)
                        Severity: Major
                        Found in src/model/sparql/JenaTextSparql.php - About 50 mins to fix

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

                                  } elseif (isset($vocabStats[$arrayClass])) {
                                      $ret['arrays'] = array(
                                          'class' => $arrayClass,
                                          'label' => isset($vocabStats[$arrayClass]['label']) ? $vocabStats[$arrayClass]['label'] : $this->model->getText(EasyRdf\RdfNamespace::shorten($arrayClass)),
                                          'count' => $vocabStats[$arrayClass]['count'],
                          Severity: Minor
                          Found in src/controller/RestController.php and 1 other location - About 50 mins to fix
                          src/controller/RestController.php on lines 312..319

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language