ndlib/marble-website-starter

View on GitHub

Showing 61 of 67 total issues

Function SeoContent has 118 lines of code (exceeds 50 allowed). Consider refactoring.
Open

export const SeoContent = (props) => {
  const {
    thumbnail,
    title,
    author,

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

    module.exports = (standardJson) => {
      const currentSource = dataLookUp[standardJson.sourceSystem.toLowerCase()]
      return Object.entries(currentSource).map(([id, data]) => {
        if (data.processor) {
          return {
    @ndlib/gatsby-source-appsync-marble/src/getItems/transform/makeMetadataArray/index.js on lines 3..17
    @ndlib/gatsby-theme-marble/src/utils/mapStandardJson/makeMetadataArray.js on lines 4..18

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

    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

    module.exports = (item) => {
      const currentSource = dataLookUp[item.sourceSystem.toLowerCase()]
      return Object.entries(currentSource).map(([id, data]) => {
        if (data.processor) {
          return {
    @ndlib/gatsby-theme-marble/src/utils/mapStandardJson/makeMetadataArray.js on lines 4..18
    @ndlib/gatsby-transformer-marbleitem/src/mapStandardJson/makeMetadataArray.js on lines 3..17

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

    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

    module.exports = (standardJson) => {
      const currentSource = dataLookUp[standardJson.sourceSystem.toLowerCase()]
      return Object.entries(currentSource).map(([id, data]) => {
        if (data.processor) {
          return {
    @ndlib/gatsby-source-appsync-marble/src/getItems/transform/makeMetadataArray/index.js on lines 3..17
    @ndlib/gatsby-transformer-marbleitem/src/mapStandardJson/makeMetadataArray.js on lines 3..17

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

    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 exports has 109 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    module.exports = (itemId, website, childrenNextToken) => {
      return `{
      getItem(id: "${itemId}", websiteId: "${website}") {
        TYPE
        access
    Severity: Major
    Found in @ndlib/gatsby-source-appsync-marble/src/getItems/queryItem.js - About 3 hrs to fix

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

      const fixLevel = (standardJson) => {
        if (standardJson.level === 'collection' && testHasFiles(standardJson)) {
          standardJson.level = 'manifest'
        } else if (testHasItems(standardJson)) {
          standardJson.items.forEach(item => fixLevel(item))
      @ndlib/gatsby-theme-marble/src/utils/pruneEmptyLeaves/index.js on lines 9..15

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

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

      const fixLevel = (standardJson) => {
        if (standardJson.level === 'collection' && testHasFiles(standardJson)) {
          standardJson.level = 'manifest'
        } else if (testHasItems(standardJson)) {
          standardJson.items.forEach(item => fixLevel(item))
      @ndlib/gatsby-transformer-marbleitem/src/pruneEmptyLeaves/index.js on lines 9..15

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

      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

      const listAll = (item, id) => {
        if (id in item && item[id]) {
          let renderedList = ''
          Object.values(item[id]).forEach(val => {
            if (val !== '') {
      @ndlib/gatsby-transformer-marbleitem/src/mapStandardJson/makeMetadataArray.js on lines 39..50

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

      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

      const listAll = (standardJson, id) => {
        if (id in standardJson && standardJson[id]) {
          let renderedList = ''
          Object.values(standardJson[id]).forEach(val => {
            if (val !== '') {
      @ndlib/gatsby-source-appsync-marble/src/getItems/transform/makeMetadataArray/index.js on lines 39..50

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

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

        Link: jest.fn().mockImplementation(
          // these props are invalid for an `a` tag
          ({
            activeClassName,
            activeStyle,
      Severity: Major
      Found in @ndlib/gatsby-theme-marble/__mocks__/gatsby.js and 1 other location - About 2 hrs to fix
      @ndlib/gatsby-source-appsync-marble/__mocks__/gatsby.js on lines 7..23

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

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

        Link: jest.fn().mockImplementation(
          // these props are invalid for an `a` tag
          ({
            activeClassName,
            activeStyle,
      Severity: Major
      Found in @ndlib/gatsby-source-appsync-marble/__mocks__/gatsby.js and 1 other location - About 2 hrs to fix
      @ndlib/gatsby-theme-marble/__mocks__/gatsby.js on lines 7..23

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

      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

      File api.js has 266 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import typy from 'typy'
      import { encode, decode } from 'js-base64'
      
      export const savePortfolioUser = ({ user, loginReducer }) => {
        const query = JSON.stringify({
      Severity: Minor
      Found in @ndlib/gatsby-theme-marble/src/utils/api.js - About 2 hrs to fix

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

        const childrenHaveFiles = (standardJson) => {
          if (!standardJson.items) {
            return false
          } else if (testHasFiles(standardJson)) {
            return true
        @ndlib/gatsby-theme-marble/src/utils/pruneEmptyLeaves/index.js on lines 65..76

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

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

        const childrenHaveFiles = (standardJson) => {
          if (!standardJson.items) {
            return false
          } else if (testHasFiles(standardJson)) {
            return true
        @ndlib/gatsby-transformer-marbleitem/src/pruneEmptyLeaves/index.js on lines 65..76

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

        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

        module.exports = (standardJson, slug) => {
          if (standardJson.repository) {
            if (standardJson.repository.toLowerCase() === 'museum') {
              return museumCitation(standardJson)
            } else if (standardJson.repository.toLowerCase() === 'rare' || standardJson.repository.toLowerCase() === 'unda') {
        @ndlib/gatsby-theme-marble/src/utils/mapStandardJson/citationGenerator.js on lines 2..11
        @ndlib/gatsby-source-appsync-marble/src/getItems/transform/citationGenerator/index.js on lines 2..11

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

        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

        module.exports = (standardJson, slug) => {
          if (standardJson.repository) {
            if (standardJson.repository.toLowerCase() === 'museum') {
              return museumCitation(standardJson)
            } else if (standardJson.repository.toLowerCase() === 'rare' || standardJson.repository.toLowerCase() === 'unda') {
        @ndlib/gatsby-transformer-marbleitem/src/mapStandardJson/citationGenerator.js on lines 2..11
        @ndlib/gatsby-source-appsync-marble/src/getItems/transform/citationGenerator/index.js on lines 2..11

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

        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

        module.exports = (item, slug) => {
          if (item.repository) {
            if (item.repository.toLowerCase() === 'museum') {
              return museumCitation(item)
            } else if (item.repository.toLowerCase() === 'rare' || item.repository.toLowerCase() === 'unda') {
        @ndlib/gatsby-theme-marble/src/utils/mapStandardJson/citationGenerator.js on lines 2..11
        @ndlib/gatsby-transformer-marbleitem/src/mapStandardJson/citationGenerator.js on lines 2..11

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

        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 TombstoneMetadata has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        const TombstoneMetadata = ({ marbleItem }) => {
          const creators = filterForLabledField(marbleItem, 'Creator')
          const dates = filterForLabledField(marbleItem, 'Date')
          const campusLocations = filterForLabledField(marbleItem, 'Campus Location')
          const uriValue = filterForLabledField(marbleItem, 'URI Value')

        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 exports has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = (item) => {
          if (item) {
            // some fields may not be null when there is no defaultImage so check the two we care about
            if (item.defaultImage && item.defaultImage.mediaServer && item.defaultImage.mediaResourceId) {
              const iiifImage = getIiif(item.defaultImage)

        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 SchemaJsonLd has 60 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        export const SchemaJsonLd = (props) => {
          const {
            thumbnail,
            pathname,
            title,
          Severity
          Category
          Status
          Source
          Language