SU-SWS/caw_profile

View on GitHub

Showing 310 of 395 total issues

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

      {
        test: /\.(png|jpg|gif)$/i,
        use: [
          // A loader for webpack which transforms files into base64 URIs.
          // https://github.com/webpack-contrib/url-loader
Severity: Major
Found in modules/caw_profile_helper/styles/webpack.config.js and 1 other location - About 1 hr to fix
modules/caw_profile_helper/styles/webpack.config.js on lines 148..169

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

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

      {
        test: /\.(svg)$/i,
        use: [
          // A loader for webpack which transforms files into base64 URIs.
          // https://github.com/webpack-contrib/url-loader
Severity: Major
Found in modules/caw_profile_helper/styles/webpack.config.js and 1 other location - About 1 hr to fix
modules/caw_profile_helper/styles/webpack.config.js on lines 125..146

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

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

export default class OnHome extends EventAbstract {

  /**
   * Execute the action to the event.
   */
themes/stanford_basic/src/js/components/secondary-nav/common/events/OnEnd.js on lines 8..21

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

export default class OnEnd extends EventAbstract {

  /**
   * Execute the action to the event.
   */
themes/stanford_basic/src/js/components/secondary-nav/common/events/OnHome.js on lines 8..21

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

Method getSnowData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  protected function getSnowData($site_name) {
    $api_url = Settings::get('caw_profile_snow_api_url', self::SNOW_API);
    try {
      $response = $this->client->request('GET', $api_url, [
        'query' => ['website_address' => $site_name],
Severity: Minor
Found in src/Plugin/InstallTask/SiteSettings.php - About 1 hr to fix

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

        if (this.parentNav.isExpanded()) {
          event.stopPropagation();
          event.preventDefault();
          this.parentNav.closeSubNav();
          this.getElement('parentItem').focus();
    themes/stanford_basic/src/js/components/secondary-nav/buttons/events/SubNavToggleArrowDown.js on lines 18..33

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

    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

        if (this.parentNav.isExpanded()) {
          event.stopPropagation();
          event.preventDefault();
          this.getElement('firstSubnavLink').focus();
        }
    themes/stanford_basic/src/js/components/secondary-nav/buttons/events/SubNavToggleArrowUp.js on lines 18..34

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

    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 exec has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      exec() {
        this.event.preventDefault();
    
        // Go to the first subnav item.
        let node = this.getElement('firstSubnavLink');

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

        public function loadOverrides($names) {
          $overrides = [];
          if (in_array('system.site', $names)) {
            $overrides['system.site']['page'] = [
              403 => $this->state->get('caw_profile.403_page'),
      Severity: Minor
      Found in src/Config/ConfigOverrides.php - About 1 hr to fix

        Function constructor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor(element, options = {}) {
            // What HTML element this is bound to.
            this.elem = element;
        
            // Set some default options.

          Function exec has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            exec() {
              const shifted = event.shiftKey;
              let firstItem = false;
              let lastItem = false;
          
          

            Function insert has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        insert: (styleTag) => {
                          var styleTarget = styleTag.dataset.styleFor
            
                          if (!styleTarget) {
                            console.error(
            Severity: Minor
            Found in themes/stanford_basic/decoupled-menu/webpack.config.js - About 1 hr to fix

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

                public function runTask(array &$install_state) {
                  $this->state->set('nobots', FALSE);
              
                  $node_pages = [
                    '403_page' => '4b8018dc-49a6-4018-9c54-e8c3e462beee',
              Severity: Minor
              Found in src/Plugin/InstallTask/SiteSettings.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

                protected function getBlog() {
                  $help = '<h3>' . self::getLinkString($this->t('Stanford Web Services Blog'), 'https://swsblog.stanford.edu/') . '</h3>';
                  $help .= '<p>' . $this->t('The Stanford Web Services team blogs about all things related to Stanford Sites, Drupal, design, site building, and many other topics. This is a great resource for SWS clients.') . '</p>';
                  return ['#markup' => $help];
                }
              Severity: Major
              Found in src/Plugin/HelpSection/ProfileResourceSection.php and 2 other locations - About 45 mins to fix
              src/Plugin/HelpSection/ProfileResourceSection.php on lines 38..42
              src/Plugin/HelpSection/ProfileResourceSection.php on lines 62..66

              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

                protected function getTechTraining() {
                  $help = '<h3>' . self::getLinkString($this->t('University IT Technology Training'), 'https://itservices.stanford.edu/service/techtraining/schedule') . '</h3>';
                  $help .= '<p>' . $this->t('Check the upcoming courses schedule for training courses offered to Stanford faculty and staff.') . '</p>';
                  return ['#markup' => $help];
                }
              Severity: Major
              Found in src/Plugin/HelpSection/ProfileResourceSection.php and 2 other locations - About 45 mins to fix
              src/Plugin/HelpSection/ProfileResourceSection.php on lines 50..54
              src/Plugin/HelpSection/ProfileResourceSection.php on lines 62..66

              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

                protected function getMorningOfCode() {
                  $help = '<h3>' . self::getLinkString($this->t("Mornings o' Code, Drupallers Drop-in Help, Drupallers Co-Working Sessions"), 'https://opensource.stanford.edu/moc') . '</h3>';
                  $help .= '<p>' . $this->t("Stanford Drupallers (new and experienced) meet regularly to collaborate and troubleshoot issues. Check the schedule for upcoming co-working sessions.") . '</p>';
                  return ['#markup' => $help];
                }
              Severity: Major
              Found in src/Plugin/HelpSection/ProfileResourceSection.php and 2 other locations - About 45 mins to fix
              src/Plugin/HelpSection/ProfileResourceSection.php on lines 38..42
              src/Plugin/HelpSection/ProfileResourceSection.php on lines 50..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 EventSubscriber has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
              Open

              class EventSubscriber implements EventSubscriberInterface {
              
                /**
                 * External site url to fetch the given file from.
                 */

              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 SiteSettings has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13.
              Open

              class SiteSettings extends InstallTaskBase implements ContainerFactoryPluginInterface {
              
                /**
                 * The fallback site name.
                 */

              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

              Variable $conditions is undefined.
              Open

                    [$role, $conditions] = explode(':', $mapping, 2);

              Variable $value is undefined.
              Open

                      'value' => $value,
              Severity
              Category
              Status
              Source
              Language