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;
- Read upRead up
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');
- Read upRead up
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();
- Read upRead up
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();
- Read upRead up
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);
- Read upRead up
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();
- Read upRead up
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)) {
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");
}
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());
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)) {
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);
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);
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();
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)) {
- Read upRead up
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)
Method generateAlphabeticalListQuery
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function generateAlphabeticalListQuery($letter, $lang, $limit, $offset, $classes, $showDeprecated = false, $qualifier = null)
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)
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)
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)
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'],
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76