NatLibFi/Skosmos

View on GitHub

Showing 1,049 of 1,049 total issues

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

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

                          public function getDefaultConceptSidebarView()
                          {
                              $defview = $this->resource->getLiteral('skosmos:defaultConceptSidebarView');
                              $sidebarViews = $this->getSidebarViews();
                              if ($defview) {
                      Severity: Major
                      Found in src/model/VocabularyConfig.php and 1 other location - About 1 hr to fix
                      src/model/VocabularyConfig.php on lines 559..577

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

                      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 getDefaultSidebarView()
                          {
                              $defview = $this->resource->getLiteral('skosmos:defaultSidebarView');
                              $sidebarViews = $this->getSidebarViews();
                              if ($defview) {
                      Severity: Major
                      Found in src/model/VocabularyConfig.php and 1 other location - About 1 hr to fix
                      src/model/VocabularyConfig.php on lines 583..601

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

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

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

                              public function invokeFeedbackForm($request)
                              {
                                  $template = $this->twig->load('feedback.twig');
                                  $this->model->setLocale($request->getLang());
                                  $vocabList = $this->model->getVocabularyList(false);
                          Severity: Minor
                          Found in src/controller/WebController.php - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language