concord-consortium/rigse

View on GitHub
rails/react-components/src/library/components/stem-finder-result.tsx

Summary

Maintainability
F
4 days
Test Coverage

File stem-finder-result.tsx has 362 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from "react";
import Component from "../helpers/component";
import { MakeTeacherEditionLink } from "../helpers/make-teacher-edition-links";
import GradeLevels from "./grade-levels";
import StemFinderResultStandards from "./stem-finder-result-standards";
Severity: Minor
Found in rails/react-components/src/library/components/stem-finder-result.tsx - About 4 hrs to fix

    StemFinderResult has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    const StemFinderResult = Component({
      getInitialState () {
        return {
          favorited: this.props.resource.is_favorite,
          hovering: false,
    Severity: Minor
    Found in rails/react-components/src/library/components/stem-finder-result.tsx - About 3 hrs to fix

      Function renderLinks has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        renderLinks () {
          const { resource } = this.props;
          const isCollection = resource.material_type === "Collection";
          const isAssignWrapped = window.self !== window.top &&
            window.self.location.hostname === window.top?.location.hostname;
      Severity: Minor
      Found in rails/react-components/src/library/components/stem-finder-result.tsx - About 2 hrs 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

      Function renderLinks has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        renderLinks () {
          const { resource } = this.props;
          const isCollection = resource.material_type === "Collection";
          const isAssignWrapped = window.self !== window.top &&
            window.self.location.hostname === window.top?.location.hostname;
      Severity: Major
      Found in rails/react-components/src/library/components/stem-finder-result.tsx - About 2 hrs to fix

        Function render has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render () {
            const { resource, index } = this.props;
            const resourceTypeClass = resource.material_type.toLowerCase();
            const finderResultClasses = this.state.isOpen ? `resourceItem ${css.finderResult} ${css.open} ${css[resourceTypeClass]}` : `resourceItem ${css.finderResult} ${css[resourceTypeClass]}`;
            const resourceName = resource.name;

          Function toggleFavorite has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            toggleFavorite (e: any) {
              e.preventDefault();
              e.stopPropagation();
          
              if (!Portal.currentUser.isLoggedIn || !Portal.currentUser.isTeacher) {

            Function renderTimeRequired has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              renderTimeRequired () {
                const resource = this.props.resource;
                const timeRequired = resource.material_type === "Activity"
                  ? "45 Minutes"
                  : resource.material_type === "Investigation"
            Severity: Minor
            Found in rails/react-components/src/library/components/stem-finder-result.tsx - About 35 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

                const teacherResourcesLink = resource.links.teacher_resources && Portal.currentUser.isTeacher
                  ? <a href={resource.links.teacher_resources.url} target="_blank" rel="noopener noreferrer" onClick={this.handleTeacherResourcesClick}>{ resource.links.teacher_resources.text }</a>
                  : null;
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 266..268
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 272..274

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

            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

                const rubricDocLink = resource.links.rubric_doc && Portal.currentUser.isTeacher
                  ? <a href={resource.links.rubric_doc.url} target="_blank" rel="noopener noreferrer" onClick={this.handleRubricDocClick}>{ resource.links.rubric_doc.text }</a>
                  : null;
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 266..268
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 269..271

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

            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

                const teacherGuideLink = resource.links.teacher_guide && Portal.currentUser.isTeacher
                  ? <a href={resource.links.teacher_guide.url} target="_blank" rel="noopener noreferrer" onClick={this.handleTeacherGuideClick}>{ resource.links.teacher_guide.text }</a>
                  : null;
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 269..271
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 272..274

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

            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

                    <div className={css.finderResultImagePreview}>
                      <img alt={resource.name} src={resource.icon.url} />
                    </div>
            rails/react-components/src/library/components/featured-collections/featured-collections-card.tsx on lines 12..14

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

            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

                        ? <a className={css.previewLinkButton} href={resource.links.preview.url} target="_blank" onClick={this.handlePreviewClick} rel="noreferrer">{ resource.links.preview.text }</a>
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 392..392

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

            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

                        : <a className={css.previewLinkButton} href={resource.links.preview.url} target="_blank" onClick={this.handleViewCollectionClick} rel="noreferrer">View Collection</a>
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 391..391

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

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

              handleRubricDocClick (e: any) {
                const { resource } = this.props;
                gtag("event", "click", {
                  "category": "Resource Rubric Doc Button",
                  "resource": resource.name
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 172..178
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 180..186
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 188..194
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 196..202
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 212..218
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 220..226
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 228..234

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

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

              handlePreviewClick (e: any) {
                const { resource } = this.props;
                gtag("event", "click", {
                  "category": "Resource Preview Button",
                  "resource": resource.name
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 180..186
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 188..194
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 196..202
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 204..210
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 212..218
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 220..226
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 228..234

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

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

              handleViewCollectionClick (e: any) {
                const { resource } = this.props;
                gtag("event", "click", {
                  "category": "Resource View Collection Button",
                  "resource": resource.name
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 172..178
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 188..194
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 196..202
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 204..210
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 212..218
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 220..226
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 228..234

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

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

              handleTeacherResourcesClick (e: any) {
                const { resource } = this.props;
                gtag("event", "click", {
                  "category": "Resource Teacher Resources Button",
                  "resource": resource.name
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 172..178
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 180..186
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 188..194
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 204..210
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 212..218
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 220..226
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 228..234

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

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

              handleAssignClick (e: any) {
                const { resource } = this.props;
                gtag("event", "click", {
                  "category": "Assign to Class Button",
                  "resource": resource.name
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 172..178
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 180..186
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 188..194
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 196..202
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 204..210
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 220..226
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 228..234

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

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

              handleTeacherEditionClick (e: any) {
                const { resource } = this.props;
                gtag("event", "click", {
                  "category": "Resource Teacher Edition Button",
                  "resource": resource.name
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 172..178
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 180..186
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 196..202
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 204..210
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 212..218
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 220..226
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 228..234

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

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

              handleAddToCollectionClick (e: any) {
                const { resource } = this.props;
                gtag("event", "click", {
                  "category": "Add to Collection Button",
                  "resource": resource.name
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 172..178
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 180..186
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 188..194
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 196..202
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 204..210
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 212..218
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 220..226

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

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

              handleTeacherGuideClick (e: any) {
                const { resource } = this.props;
                gtag("event", "click", {
                  "category": "Teacher Guide Link",
                  "resource": resource.name
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 172..178
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 180..186
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 188..194
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 196..202
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 204..210
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 212..218
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 228..234

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

            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

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

                const isAssignWrapped = window.self !== window.top &&
                  window.self.location.hostname === window.top?.location.hostname;
            rails/react-components/src/library/components/materials-bin/material.tsx on lines 25..25
            rails/react-components/src/library/components/materials-bin/materials-collection.tsx on lines 6..6

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

            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 (!resource.is_official && (resource.publication_status === "private")) {
                  return (
                    <div className={`${css.metaTag} ${css.private}`}>
                      Private
                    </div>
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 150..156

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

            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 (!resource.is_official && (resource.publication_status === "published")) {
                  return (
                    <div className={`${css.metaTag} ${css.community}`}>
                      Community
                    </div>
            rails/react-components/src/library/components/stem-finder-result.tsx on lines 142..148

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

            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

            There are no issues that match your filters.

            Category
            Status