Showing 49 of 61 total issues
File PbjxBatchCommand.php
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Gdbots\Bundle\PbjxBundle\Command;
Method load
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function load(array $configs, ContainerBuilder $container): void
{
$processor = new Processor();
$configuration = new Configuration();
$configs = $processor->processConfiguration($configuration, $configs);
Method execute
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output): int
{
$errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
$curie = SchemaCurie::fromString($input->getArgument('curie'));
Function execute
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output): int
{
$errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);
- 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 configure
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function configure(): void
{
$this
->setDescription('Handles pbjx messages (command, event, request) and returns an envelope with the result')
->setHelp(<<<EOF
Method execute
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output): int
{
$errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);
Method isPbjxTokenOk
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function isPbjxTokenOk(Message $envelope, Request $request, string $content): bool
{
if ($request->attributes->getBoolean('pbjx_console')) {
// no tokens used on the console
return true;
Method onKernelView
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onKernelView(ViewEvent $event): void
{
$envelope = $event->getControllerResult();
if (!$envelope instanceof EnvelopeV1) {
return;
Function receiveAction
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function receiveAction(Request $request): JsonResponse
{
if (!$this->enabled) {
throw new AccessDeniedHttpException(
'The receive endpoint is not enabled.',
- 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 isPbjxTokenOk
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function isPbjxTokenOk(Message $envelope, Request $request, string $content): bool
{
if ($request->attributes->getBoolean('pbjx_console')) {
// no tokens used on the console
return true;
- 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 configure
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function configure(): void
{
$provider = $this->container->getParameter('gdbots_pbjx.event_store.provider');
$this
Method process
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process(ContainerBuilder $container): void
{
$locator = $container->getDefinition('gdbots_pbjx.service_locator');
foreach ($container->findTaggedServiceIds('pbjx.handler') as $id => $attributes) {
Function reindex
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function reindex(array $events, array $context, bool $skipErrors): int
{
$count = count($events);
if ($count === 0) {
return 0;
- 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 handleException
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleException(Message $envelope, Request $request, Message $message, \Throwable $exception): Message
{
if ($exception instanceof HttpExceptionInterface) {
$httpCode = HttpCode::tryFrom($exception->getStatusCode()) ?: HttpCode::UNKNOWN;
$code = StatusCodeUtil::httpToVendor($httpCode);
Method execute
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output): int
{
$errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);
Consider simplifying this complex logical expression. Open
if (
null === ($class = $container->getDefinition($id)->getClass())
|| !($r = $container->getReflectionClass($class, false))
|| !$r->hasMethod($method)
|| 1 > ($m = $r->getMethod($method))->getNumberOfParameters()
Function execute
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function execute(InputInterface $input, OutputInterface $output): int
{
$errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);
- 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 onKernelView
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function onKernelView(ViewEvent $event): void
{
$envelope = $event->getControllerResult();
if (!$envelope instanceof EnvelopeV1) {
return;
- 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 reindexBatch
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function reindexBatch(SymfonyStyle $io, array $events, array $context, int $batch, bool $dryRun, bool $skipErrors): int
Function restrictBind
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function restrictBind(PbjxEvent $pbjxEvent, Message $message, array $restrictedFields, array $input): void
{
foreach ($restrictedFields as $field) {
if (!$message->has($field)) {
// this means whatever was in the input never made it to the message.
- 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"