includes/Search/Rescore/FunctionScoreChain.php
Method getImplementation
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function getImplementation( $func ) {
$weight = $func['weight'] ?? 1;
$config = $this->context->getConfig();
switch ( $func['type'] ) {
case 'boostlinks':
Function getImplementation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
private function getImplementation( $func ) {
$weight = $func['weight'] ?? 1;
$config = $this->context->getConfig();
switch ( $func['type'] ) {
case 'boostlinks':
- 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
Avoid too many return
statements within this method. Open
Open
return new NamespacesFunctionScoreBuilder( $config, $this->context->getNamespaces(), $weight );
Avoid too many return
statements within this method. Open
Open
return $builder;
Avoid too many return
statements within this method. Open
Open
return new ScriptScoreFunctionScoreBuilder( $config, $weight, $func['script'] );
Avoid too many return
statements within this method. Open
Open
return new LangWeightFunctionScoreBuilder( $config, $weight );
Avoid too many return
statements within this method. Open
Open
return new SatuFunctionScoreBuilder( $config, $weight, $func['params'] );
Avoid too many return
statements within this method. Open
Open
return new CustomFieldFunctionScoreBuilder( $config, $weight, $func['params'] );
Avoid too many return
statements within this method. Open
Open
return new GeoMeanFunctionScoreBuilder( $config, $weight, $func['params'] );
Avoid too many return
statements within this method. Open
Open
return new LogScaleBoostFunctionScoreBuilder( $config, $weight, $func['params'] );
Avoid too many return
statements within this method. Open
Open
return new LogMultFunctionScoreBuilder( $config, $weight, $func['params'] );
Avoid too many return
statements within this method. Open
Open
return new TermBoostScoreBuilder( $config, $weight, $func['params'] );
Function buildRescoreQuery
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
public function buildRescoreQuery() {
if ( !isset( $this->chain['functions'] ) ) {
throw new InvalidRescoreProfileException( "No functions defined in chain {$this->chainName}." );
}
foreach ( $this->chain['functions'] as $func ) {
- 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"