NatLibFi/Skosmos

View on GitHub

Showing 1,049 of 1,049 total issues

Method generateParentListQuery has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function generateParentListQuery($uri, $lang, $fallback, $props)
    {
        $fcl = $this->generateFromClause();
        $propertyClause = implode('|', $props);
        $query = <<<EOQ
Severity: Minor
Found in src/model/sparql/GenericSparql.php - About 1 hr to fix

    Method generateAlphabeticalListQuery has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function generateAlphabeticalListQuery($letter, $lang, $limit, $offset, $classes, $showDeprecated = false, $qualifier = null)
        {
            $gcl = $this->graphClause;
            $classes = ($classes) ? $classes : array('http://www.w3.org/2004/02/skos/core#Concept');
            $values = $this->formatValues('?type', $classes, 'uri');
    Severity: Minor
    Found in src/model/sparql/GenericSparql.php - About 1 hr to fix

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

        Function transformNarrowerResults has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private function transformNarrowerResults($result, $lang)
            {
                $ret = array();
                foreach ($result as $row) {
                    if (!isset($row->child)) {
        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 searchConceptsAndInfo has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function searchConceptsAndInfo($params)
            {
                $params->setUnique(true);
                $allhits = $this->searchConcepts($params);
                $count = sizeof($allhits);
        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 transformSearchResults has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private function transformSearchResults($request, $results, $parameters)
            {
                // before serializing to JSON, get rid of the Vocabulary object that came with each resource
                foreach ($results as &$res) {
                    unset($res['voc']);
        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 getTypes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getTypes($vocid = null, $lang = null)
            {
                $sparql = (isset($vocid)) ? $this->getVocabulary($vocid)->getSparql() : $this->getDefaultSparql();
                $result = $sparql->queryTypes($lang);
                foreach ($result as $uri => $values) {
        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 invokeGlobalSearch has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function invokeGlobalSearch($request)
            {
                $lang = $request->getLang();
                $template = $this->twig->load('global-search.twig');
                $this->model->setLocale($request->getLang());
        Severity: Minor
        Found in src/controller/WebController.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 getPluginArray has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getPluginArray(): array
            {
                $this->setParameterizedPlugins();
                $pluginArray = 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

        Method labelStatistics has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function labelStatistics($request)
            {
                if ($this->notModified($request->getVocab())) {
                    return null;
                }
        Severity: Minor
        Found in src/controller/RestController.php - About 1 hr to fix

          Method transformSearchResults has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function transformSearchResults($request, $results, $parameters)
              {
                  // before serializing to JSON, get rid of the Vocabulary object that came with each resource
                  foreach ($results as &$res) {
                      unset($res['voc']);
          Severity: Minor
          Found in src/controller/RestController.php - About 1 hr to fix

            Avoid excessively long variable names like $DEFAULT_EXT_PROPERTIES. Keep variable name length under 20.
            Open

                private $DEFAULT_EXT_PROPERTIES = array(
                    "dc11:title",
                    "dcterms:title",
                    "skos:prefLabel",
                    "skos:exactMatch",
            Severity: Minor
            Found in src/model/Concept.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $globalPluginsResource. Keep variable name length under 20.
            Open

                    $globalPluginsResource =  $this->getResource()->getResource("skosmos:globalPlugins");
            Severity: Minor
            Found in src/model/GlobalConfig.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $defaultConceptSchemeURI. Keep variable name length under 20.
            Open

                public function getConceptScheme(string $defaultConceptSchemeURI)
            Severity: Minor
            Found in src/model/Vocabulary.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Method queryTopConcepts has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function queryTopConcepts($conceptSchemes, $lang, $fallback)
                {
                    if (!is_array($conceptSchemes)) {
                        $conceptSchemes = array($conceptSchemes);
                    }
            Severity: Minor
            Found in src/model/sparql/GenericSparql.php - About 1 hr to fix

              Method vocabularyInformation has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Method searchConceptsAndInfo has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function searchConceptsAndInfo($params)
                    {
                        $params->setUnique(true);
                        $allhits = $this->searchConcepts($params);
                        $count = sizeof($allhits);
                Severity: Minor
                Found in src/model/Model.php - About 1 hr to fix

                  Function renderResults has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      renderResults () {
                        // TODO: get the results list form cache if it is implemented
                        const renderedSearchTerm = this.searchTerm // save the search term in case it changes while rendering
                  
                        this.renderedResultsList.forEach(result => {
                  Severity: Minor
                  Found in resource/js/vocab-search.js - About 1 hr to fix

                    Method dumpJsonLd has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function dumpJsonLd()
                        {
                            $context = array(
                                'skos' => EasyRdf\RdfNamespace::get("skos"),
                                'isothes' => EasyRdf\RdfNamespace::get("isothes"),
                    Severity: Minor
                    Found in src/model/Concept.php - About 1 hr to fix

                      Method getMappingProperties has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getMappingProperties(array $whitelist = null)
                          {
                              $ret = array();
                      
                              $longUris = $this->resource->propertyUris();
                      Severity: Minor
                      Found in src/model/Concept.php - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language