SU-SWS/stanford_profile_helper

View on GitHub

Showing 398 of 591 total issues

Method insertOrgData has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  protected function insertOrgData(array $org_data, TermInterface $parent = NULL): void {
    if (!isset($org_data['orgCodes'])) {
      return;
    }

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

      public function blockForm($form, FormStateInterface $form_state) {
        $form = parent::blockForm($form, $form_state);
        $config = $this->getConfiguration();
    
        $form['heading_text'] = [
    Severity: Minor
    Found in modules/jumpstart_ui/src/Plugin/Block/PageHeadingBlock.php - About 1 hr to fix

      Method getRomanNumeral has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        protected function getRomanNumeral(int $num): string {
          $map = [
            'M' => 1000,
            'CM' => 900,
            'D' => 500,

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

            $fields['parent_type'] = BaseFieldDefinition::create('string')
              ->setLabel(t('Parent type'))
              ->setDescription(t('The entity parent type to which this entity is referenced.'))
              ->setSetting('is_ascii', TRUE)
              ->setSetting('max_length', EntityTypeInterface::ID_MAX_LENGTH);
        Severity: Minor
        Found in modules/stanford_publication/src/Entity/Citation.php and 1 other location - About 55 mins to fix
        modules/stanford_publication/src/Entity/Citation.php on lines 115..119

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

        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

            $fields['parent_field_name'] = BaseFieldDefinition::create('string')
              ->setLabel(t('Parent field name'))
              ->setDescription(t('The entity parent field name to which this entity is referenced.'))
              ->setSetting('is_ascii', TRUE)
              ->setSetting('max_length', FieldStorageConfig::NAME_MAX_LENGTH);
        Severity: Minor
        Found in modules/stanford_publication/src/Entity/Citation.php and 1 other location - About 55 mins to fix
        modules/stanford_publication/src/Entity/Citation.php on lines 109..113

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

        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 3 locations. Consider refactoring.
        Open

          public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
            return new static(
              $plugin_id,
              $plugin_definition,
              $configuration['field_definition'],
        modules/stanford_courses/src/Plugin/Field/FieldWidget/ExploreCoursesUrlWidget.php on lines 38..47
        modules/stanford_events/modules/stanford_events_importer/src/Plugin/Field/FieldWidget/StanfordEventsImporterAPIURLFieldWidget.php on lines 51..53

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

        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 3 locations. Consider refactoring.
        Open

          public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
            return new static(
              $plugin_id,
              $plugin_definition,
              $configuration['field_definition'],
        modules/stanford_events/modules/stanford_events_importer/src/Plugin/Field/FieldWidget/StanfordEventsImporterAPIURLFieldWidget.php on lines 51..53
        modules/stanford_intranet/src/Plugin/Field/FieldWidget/EntityAccessFieldWidget.php on lines 37..46

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

        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 3 locations. Consider refactoring.
        Open

          public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
            return new static($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings'], $configuration['third_party_settings'], $container->get('cache.default'));
          }
        modules/stanford_courses/src/Plugin/Field/FieldWidget/ExploreCoursesUrlWidget.php on lines 38..47
        modules/stanford_intranet/src/Plugin/Field/FieldWidget/EntityAccessFieldWidget.php on lines 37..46

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

        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

        Function createParagraph has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
        Open

          protected function createParagraph($bundle): EntityInterface {
            // We've already created this paragraph type, just duplicated i.
            if (isset($this->paragraphs[$bundle])) {
              return $this->paragraphs[$bundle]->createDuplicate();
            }
        Severity: Minor
        Found in modules/stanford_profile_drush/src/Commands/StanfordProfileCommands.php - About 45 mins 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

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

          public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, StateInterface $state) {
            parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
            $this->state = $state;
          }
        modules/stanford_courses/src/Plugin/Field/FieldWidget/ExploreCoursesUrlWidget.php on lines 60..63
        modules/stanford_events/modules/stanford_events_importer/src/Plugin/Field/FieldWidget/StanfordEventsImporterAPIURLFieldWidget.php on lines 58..61

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

        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 3 locations. Consider refactoring.
        Open

          public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, CacheBackendInterface $cache) {
            parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
            $this->cache = $cache;
          }
        modules/stanford_courses/src/Plugin/Field/FieldWidget/ExploreCoursesUrlWidget.php on lines 60..63
        modules/stanford_intranet/src/Plugin/Field/FieldWidget/EntityAccessFieldWidget.php on lines 51..54

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

        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 3 locations. Consider refactoring.
        Open

          public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, ClientInterface $client) {
            parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
            $this->client = $client;
          }
        modules/stanford_events/modules/stanford_events_importer/src/Plugin/Field/FieldWidget/StanfordEventsImporterAPIURLFieldWidget.php on lines 58..61
        modules/stanford_intranet/src/Plugin/Field/FieldWidget/EntityAccessFieldWidget.php on lines 51..54

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

        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

        The class Cap has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
        Open

        class Cap implements CapInterface {
        
          use StringTranslationTrait;
        
          /**

        CouplingBetweenObjects

        Since: 1.1.0

        A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

        Example

        class Foo {
            /**
             * @var \foo\bar\X
             */
            private $x = null;
        
            /**
             * @var \foo\bar\Y
             */
            private $y = null;
        
            /**
             * @var \foo\bar\Z
             */
            private $z = null;
        
            public function setFoo(\Foo $foo) {}
            public function setBar(\Bar $bar) {}
            public function setBaz(\Baz $baz) {}
        
            /**
             * @return \SplObjectStorage
             * @throws \OutOfRangeException
             * @throws \InvalidArgumentException
             * @throws \ErrorException
             */
            public function process(\Iterator $it) {}
        
            // ...
        }

        Source https://phpmd.org/rules/design.html#couplingbetweenobjects

        The class StanfordPolicySubscriber has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
        Open

        class StanfordPolicySubscriber implements EventSubscriberInterface {
        
          /**
           * Flag to prevent recursion.
           *

        CouplingBetweenObjects

        Since: 1.1.0

        A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

        Example

        class Foo {
            /**
             * @var \foo\bar\X
             */
            private $x = null;
        
            /**
             * @var \foo\bar\Y
             */
            private $y = null;
        
            /**
             * @var \foo\bar\Z
             */
            private $z = null;
        
            public function setFoo(\Foo $foo) {}
            public function setBar(\Bar $bar) {}
            public function setBaz(\Baz $baz) {}
        
            /**
             * @return \SplObjectStorage
             * @throws \OutOfRangeException
             * @throws \InvalidArgumentException
             * @throws \ErrorException
             */
            public function process(\Iterator $it) {}
        
            // ...
        }

        Source https://phpmd.org/rules/design.html#couplingbetweenobjects

        Missing class doc comment
        Open

        class ImageItem extends OrigImageItem {

        Doc comment short description must end with a full stop
        Open

           * {@inheritDoc}

        Doc comment short description must start with a capital letter
        Open

           * {@inheritDoc}

        Doc comment short description must start with a capital letter
        Open

           * {@inheritDoc}.

        TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
        Open

                  'revalidate_page' => false,

        Doc comment short description must end with a full stop
        Open

           * {@inheritDoc}
        Severity
        Category
        Status
        Source
        Language