NatLibFi/Skosmos

View on GitHub

Showing 191 of 1,049 total issues

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

    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

      Method returnDataResults has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function returnDataResults($results, $format)
          {
              if ($format == 'application/ld+json' || $format == 'application/json') {
                  // further compact JSON-LD document using a context
                  $context = array(
      Severity: Minor
      Found in src/controller/RestController.php - About 1 hr to fix

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

          Function queryTopConcepts has a Cognitive Complexity of 11 (exceeds 5 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

          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 guessVocabularyFromURI has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function guessVocabularyFromURI($uri, $preferredVocabId = null)
              {
                  if ($this->vocabsByUriSpace === null) { // initialize cache
                      $this->vocabsByUriSpace = array();
                      foreach ($this->getVocabularies() as $voc) {
          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 asJskos has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function asJskos($queryExVocabs = true, $lang = null, $hrefLink = null)
              {
                  $propertyLabel = $this->getLabel($lang, $queryExVocabs);
                  $propertyLang = $lang;
                  if (!is_string($propertyLabel)) {
          Severity: Minor
          Found in src/model/ConceptMappingPropertyValue.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 combineCrumbs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function combineCrumbs($origCrumbs)
              {
                  $combined = array();
                  foreach ($origCrumbs as $pathKey => $path) {
                      $firstToCombine = true;
          Severity: Minor
          Found in src/model/Vocabulary.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 getDate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getDate()
              {
                  $ret = '';
                  $created = '';
                  try {
          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 generateQueryTypesQuery has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function generateQueryTypesQuery($lang)
              {
                  $fcl = $this->generateFromClause();
                  $query = <<<EOQ
          SELECT DISTINCT ?type ?label ?superclass $fcl
          Severity: Minor
          Found in src/model/sparql/GenericSparql.php - About 1 hr to fix

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

                public function types($request)
                {
                    $vocid = $request->getVocab() ? $request->getVocab()->getId() : null;
                    if ($vocid === null && !$request->getLang()) {
                        return $this->returnError(400, "Bad Request", "lang parameter missing");
            Severity: Minor
            Found in src/controller/RestController.php - About 1 hr to fix

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

                  private function getCollections($includeArrays)
                  {
                      $groups = array();
                      $collections = $this->graph->resourcesMatching('skos:member', $this->resource);
                      if (isset($collections)) {
              Severity: Minor
              Found in src/model/Concept.php - About 1 hr to fix

                Method vocabularies has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Method invokeVocabularyConcept has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Method getDate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function getDate()
                        {
                            $ret = '';
                            $created = '';
                            try {
                    Severity: Minor
                    Found in src/model/Concept.php - About 1 hr to fix

                      Method transformNarrowerResults has 29 lines of code (exceeds 25 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

                        Method getPluginArray has 29 lines of code (exceeds 25 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

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

                            Method generateQueryConceptSchemesQuery has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private function generateQueryConceptSchemesQuery($lang)
                                {
                                    $fcl = $this->generateFromClause();
                                    $query = <<<EOQ
                            SELECT ?cs ?label ?preflabel ?title ?domain ?domainLabel $fcl
                            Severity: Minor
                            Found in src/model/sparql/GenericSparql.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language