Code should not be duplicated 4

  • Minor
  • Architecture

More information: https://insight.symfony.com/what-we-analyse/php.duplicated_code

  1. $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config'));
  2. $loader->load('checkers.yml');
  3. if (array_key_exists('checkers', $configs)) {
  4. foreach ($this->sources as $source) {
  5. $source->load($configs['checkers'], $container);

    The next 49 lines appear in src/Bundle/JoseFramework/DependencyInjection/Source/Checker/CheckerSource.php:68, src/Bundle/JoseFramework/DependencyInjection/Source/Encryption/EncryptionSource.php:72 and src/Bundle/JoseFramework/DependencyInjection/Source/Signature/SignatureSource.php:71.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Spomky
  6. }
  7. }
  8. }
  9. /**
  1. ->end()
  2. ->arrayNode('compression_methods')
  3. ->info('A list of compression method aliases.')
  4. ->useAttributeAsKey('name')
  5. ->defaultValue(['DEF'])
  6. ->scalarPrototype()->end()

    The next 34 lines appear both in src/Bundle/JoseFramework/DependencyInjection/Source/Encryption/JWELoader.php:90 and src/Bundle/JoseFramework/DependencyInjection/Source/Signature/JWSLoader.php:76.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Spomky
  7. ->end()
  8. ->arrayNode('serializers')
  9. ->info('A list of signature serializer aliases.')
  10. ->useAttributeAsKey('name')
  11. ->requiresAtLeastOneElement()
  1. $itemConfig['compression_methods'],
  2. $itemConfig['jws_serializers'],
  3. $itemConfig['signature_algorithms'],
  4. ])
  5. ->addTag('jose.nested_token_builder')
  6. ->setPublic($itemConfig['is_public']);

    The next 64 lines appear both in src/Bundle/JoseFramework/DependencyInjection/Source/Encryption/NestedTokenBuilder.php:52 and src/Bundle/JoseFramework/DependencyInjection/Source/Encryption/NestedTokenLoader.php:54.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Spomky
  7. foreach ($itemConfig['tags'] as $id => $attributes) {
  8. $definition->addTag($id, $attributes);
  9. }
  10. $container->setDefinition($service_id, $definition);
  11. }
  1. /**
  2. * @param string $curve
  3. *
  4. * @return array
  5. */
  6. private static function createECKeyUsingPurePhp(string $curve): array

    The next 53 lines appear both in src/Component/Encryption/Algorithm/KeyEncryption/ECDHES.php:313 and src/Component/KeyManagement/JWKFactory.php:82.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Spomky
  7. {
  8. switch ($curve) {
  9. case 'P-256':
  10. $nistCurve = NistCurve::curve256();

Templates should not be too long

  • Minor
  • Codestyle

More information: https://insight.symfony.com/what-we-analyse/twig.template_too_long

20% of all your templates have more than 200 lines, the threshold is 5%.

Time to fix: about 2 hours
Open Issue Permalink
Collective

Unused method, property, variable or parameter 5

  • Minor
  • Deadcode

More information: https://insight.symfony.com/what-we-analyse/php.unused_local_variable_or_private_member

  1. }
  2. /**
  3. * @param array $completeHeader
  4. */
  5. private function checkAndSetContentEncryptionAlgorithm(array $completeHeader): void

    This checkAndSetContentEncryptionAlgorithm method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Spomky
  6. {
  7. $contentEncryptionAlgorithm = $this->getContentEncryptionAlgorithm($completeHeader);
  8. if (null === $this->contentEncryptionAlgorithm) {
  9. $this->contentEncryptionAlgorithm = $contentEncryptionAlgorithm;
  10. } elseif ($contentEncryptionAlgorithm->name() !== $this->contentEncryptionAlgorithm->name()) {
  1. /**
  2. * @param KeyEncryptionAlgorithm $keyEncryptionAlgorithm
  3. * @param JWK $recipientKey
  4. */
  5. private function checkKey(KeyEncryptionAlgorithm $keyEncryptionAlgorithm, JWK $recipientKey)

    This checkKey method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Spomky
  6. {
  7. KeyChecker::checkKeyUsage($recipientKey, 'encryption');
  8. if ('dir' !== $keyEncryptionAlgorithm->name()) {
  9. KeyChecker::checkKeyAlgorithm($recipientKey, $keyEncryptionAlgorithm->name());
  10. } else {
  1. /**
  2. * @param array $completeHeader
  3. *
  4. * @return CompressionMethod|null
  5. */
  6. private function getCompressionMethod(array $completeHeader): ?CompressionMethod

    This getCompressionMethod method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Spomky
  7. {
  8. if (!array_key_exists('zip', $completeHeader)) {
  9. return null;
  10. }
  1. * @param string $current
  2. * @param string $new
  3. *
  4. * @return bool
  5. */
  6. private function areKeyManagementModesCompatible(string $current, string $new): bool

    This areKeyManagementModesCompatible method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Spomky
  7. {
  8. $agree = KeyEncryptionAlgorithm::MODE_AGREEMENT;
  9. $dir = KeyEncryptionAlgorithm::MODE_DIRECT;
  10. $enc = KeyEncryptionAlgorithm::MODE_ENCRYPT;
  11. $wrap = KeyEncryptionAlgorithm::MODE_WRAP;
  1. /**
  2. * @param array $completeHeader
  3. *
  4. * @return KeyEncryptionAlgorithm
  5. */
  6. private function getKeyEncryptionAlgorithm(array $completeHeader): KeyEncryptionAlgorithm

    This getKeyEncryptionAlgorithm method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Spomky
  7. {
  8. if (!array_key_exists('alg', $completeHeader)) {
  9. throw new \InvalidArgumentException('Parameter "alg" is missing.');
  10. }
  11. $keyEncryptionAlgorithm = $this->keyEncryptionAlgorithmManager->get($completeHeader['alg']);