ndlib/marble-website-starter

View on GitHub

Showing 61 of 67 total issues

Function HitResult has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const HitResult = ({ hit, referal, loginReducer }) => {
  const {
    name,
    creator,
    date,

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

exports.sourceNodes = async (
  gatsbyInternal,
  pluginOptions,
) => {
  const { url, key, website, itemList, useFixtures = false, updateFixtures = false, debug = false } = pluginOptions
Severity: Minor
Found in @ndlib/gatsby-source-appsync-marble/gatsby-node.js - About 1 hr 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 exports has 52 lines of code (exceeds 50 allowed). Consider refactoring.
Open

module.exports = (parent, child) => {
  const mergedObject = {
    sequence: 0,
  }

Severity: Major
Found in @ndlib/gatsby-source-appsync-marble/src/getItems/transform/merge.js - About 1 hr to fix

    Function exports has 51 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    module.exports = async (item, pluginOptions) => {
      const { timePeriodCutoff } = pluginOptions
      const dateData = realDatesFromCatalogedDates(item.createdDate, timePeriodCutoff)
      const creators = getCreators(item)
      const themes = getKeywordsFromSubjects(item)

      Function crawlStandardJson has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const crawlStandardJson = (standardJson, collection, parent, gatsbyInternal) => {
        const { actions, createNodeId, createContentDigest } = gatsbyInternal
        const { createNode, createParentChildLink } = actions
        const nodeId = createNodeId(standardJson.id)
        if (standardJson.level && standardJson.level.toLowerCase() === 'file') {
      Severity: Minor
      Found in @ndlib/gatsby-transformer-marbleitem/src/crawlStandardJson/index.js - About 55 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

      Function NDBrandLayout has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      const NDBrandLayout = ({ location, variant, children, pageHeader, siteFooter, titleOverride }) => {
        const { menusJson } = useStaticQuery(query)
      
        const menu = typy(menusJson, 'items').safeArray
        const [showMenu, setShowMenu] = useState(false)
      Severity: Minor
      Found in @ndlib/gatsby-theme-marble/src/components/Shared/NDBrand/Layout/index.js - 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

      Function findImage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const findImage = (images, marbleItem, thumbnail = false) => {
        // the default image if it exists
        let returnImage = findDefaultImage(marbleItem, thumbnail)
      
        // check the child images if default image returned null and was assigned a "no image" image
      Severity: Minor
      Found in @ndlib/gatsby-theme-marble/src/utils/findImage.js - 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

      Function AlternateImage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const AlternateImage = ({
        allMarbleFile,
        marbleItem,
        index,
        max,

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

              <Button variant='links.navTop' className='search' title='Search' onClick={() => {
                submitSearch(location, inputRef, searchPath)
              }} sx={{
                borderRadius: '0',
                borderRightWidth: '1px',
      @ndlib/gatsby-theme-marble/src/components/Shared/NDBrand/Header/NavSearch/index.js on lines 72..92

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

      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

                  <Button
                    className='search'
                    variant='links.navTop'
                    sx={{
                      borderRadius: '0',
      @ndlib/gatsby-theme-marble/src/components/Shared/NDBrand/Header/NavSearch/index.js on lines 35..49

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

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

      const getArrayNeighbors = (arr, index, numberBeforeAndAfter) => {
        const length = arr.length
        // If array is shorter than requested number of siblings, return original array minus the item at the current index
        if (length <= (2 * numberBeforeAndAfter) + 1) {
          return arr.filter((item, i) => {
      Severity: Minor
      Found in @ndlib/gatsby-theme-marble/src/utils/getArrayNeighbors.js - 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 2 locations. Consider refactoring.
      Open

                <svg
                  xmlns='http://www.w3.org/2000/svg'
                  height='16'
                  viewBox='0 -4 24 24'
                  width='16'
      @ndlib/gatsby-theme-marble/src/components/Shared/ActionModal/index.js on lines 41..56

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

                <svg
                  xmlns='http://www.w3.org/2000/svg'
                  width='24'
                  height='24'
                  viewBox='0 0 24 24'
      @ndlib/gatsby-theme-marble/src/components/Shared/ReturnToSearch/index.js on lines 35..44

      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

      const genericFind = (item, id) => {
        if (id in item && item[id]) {
          let data = item[id]
          if (!Array.isArray(data)) {
            data = [punctuationStripper(data)]
      @ndlib/gatsby-theme-marble/src/utils/mapStandardJson/makeMetadataArray.js on lines 20..30
      @ndlib/gatsby-transformer-marbleitem/src/mapStandardJson/makeMetadataArray.js on lines 19..29

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

      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 genericFind = (standardJson, id) => {
        if (id in standardJson && standardJson[id]) {
          let data = standardJson[id]
          if (!Array.isArray(data)) {
            data = [punctuationStripper(data)]
      @ndlib/gatsby-source-appsync-marble/src/getItems/transform/makeMetadataArray/index.js on lines 19..29
      @ndlib/gatsby-theme-marble/src/utils/mapStandardJson/makeMetadataArray.js on lines 20..30

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

      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 genericFind = (standardJson, id) => {
        if (id in standardJson && standardJson[id]) {
          let data = standardJson[id]
          if (!Array.isArray(data)) {
            data = [punctuationStripper(data)]
      @ndlib/gatsby-source-appsync-marble/src/getItems/transform/makeMetadataArray/index.js on lines 19..29
      @ndlib/gatsby-transformer-marbleitem/src/mapStandardJson/makeMetadataArray.js on lines 19..29

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

      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

      Avoid too many return statements within this function.
      Open

        return 'Rare Books & Special Collections'

        Function AdditionalDescription has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const AdditionalDescription = ({ marbleItem, alignLeft = false }) => {
          const themeUi = useThemeUI()
        
          if (marbleItem && marbleItem.additionalDescription) {
            return (

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

        export const NDBrandNavSearch = ({ location, variant, searchPath, setShowSearch, forceImages, ...props }) => {
          const inputRef = React.createRef()
          const qs = queryString.parse(location.search)
        
          useEffect(() => {

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

        export const AddNewPortfolio = ({ portfolios, addFunc, loginReducer }) => {
          const [editable, setEditable] = useState(false)
          const [error, setError] = useState(false)
          const [creating, setCreating] = useState(false)
          const [title, setTitle] = useState(defaultTitle)

        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

        Severity
        Category
        Status
        Source
        Language