ctrl-alt-del-world/midway

View on GitHub

Showing 47 of 47 total issues

Function PreviewPage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const PreviewPage = ({ document }: { document: string }) => {
  const [doc, setDoc] = useState(null as any)

  
  //  @ts-ignore
Severity: Minor
Found in web/src/pages/docs.tsx - 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 PreviewPage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const PreviewPage = ({ document }: { document: string }) => {
  const [doc, setDoc] = useState(null as any)

  
  //  @ts-ignore
Severity: Minor
Found in web/src/pages/previews.tsx - 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 handleReset has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async (password) =>  {

      if (!PasswordSchema.validate(passwordField1)) {
        throw new Error(
          "Your password should be between 8 and 100 characters, and have at least one lowercase and one uppercase letter."
Severity: Minor
Found in web/src/components/auth/reset.tsx - About 1 hr to fix

    Function handler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const handler = async (event: APIGatewayEvent): Promise<any> => {
      if (event.httpMethod !== 'POST' || !event.body) return statusReturn(400, '')
      let data: {
        token: string
      }
    Severity: Minor
    Found in web/src/lambda/orders.ts - About 1 hr to fix

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

      export const ProductSchema = (main: {
        title: string
        productDescription?: []
        mainImage?: {
          asset: {
      Severity: Minor
      Found in web/src/components/product/schema.tsx - About 1 hr to fix

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

        export const handler = async (event: APIGatewayEvent): Promise<any> => {
          if (event.httpMethod !== 'POST' || !event.body) return statusReturn(400, '')
        
          try {
            data = JSON.parse(event.body)
        Severity: Minor
        Found in web/src/lambda/activate.ts - About 1 hr to fix

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

          export const PasswordWrapper = ({ children }: {
            children: any
          }) => {
            // Comment this out to turn the password back on!
            // const [password, setPassword] = useState(cookie.get('password'))
          Severity: Minor
          Found in web/src/layouts/password.tsx - 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 handler has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          export const handler = async (event: APIGatewayEvent): Promise<any> => {
            // TEST for POST request
            if (event.httpMethod !== 'POST' || !event.body) {
              return statusReturn(400, '')
            }
          Severity: Minor
          Found in web/src/lambda/register.ts - 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 handler has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          export const handler = async (event: APIGatewayEvent): Promise<any> => {
          
            // TEST for POST request
            if (event.httpMethod !== 'POST' || !event.body) {
              return statusReturn(400, '')
          Severity: Minor
          Found in web/src/lambda/reset-password.ts - 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 Reset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export const Reset = (props: {
            path: string
            id?: string
            token?: string
          }) => {
          Severity: Minor
          Found in web/src/components/auth/reset.tsx - 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

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

          const client = sanityClient({
              projectId: process.env.GATSBY_SANITY_PROJECT_ID,
              dataset: process.env.GATSBY_SANITY_DATASET,
              token: process.env.SANITY_API_TOKEN,
              useCdn: false,
          Severity: Minor
          Found in web/migrations/backup-sanity.js and 1 other location - About 45 mins to fix
          web/src/api/sanity.js on lines 3..8

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

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

          export const handler = async (event: APIGatewayEvent): Promise<any> => {
            if (event.httpMethod !== "POST" || !event.body) return statusReturn(400, '')
          
            try {
              data = JSON.parse(event.body)
          Severity: Minor
          Found in web/src/lambda/forgot-password.ts - 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

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

          module.exports = sanityClient({
            projectId: process.env.GATSBY_SANITY_PROJECT_ID,
            dataset: process.env.GATSBY_SANITY_DATASET,
            token: process.env.SANITY_API_TOKEN,
            useCdn: false
          Severity: Minor
          Found in web/src/api/sanity.js and 1 other location - About 45 mins to fix
          web/migrations/backup-sanity.js on lines 6..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 50.

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

          export const handler = async (event: APIGatewayEvent): Promise<any> => {
            if (event.httpMethod !== 'POST' || !event.body) return statusReturn(400, {})
          
            try {
              data = JSON.parse(event.body)
          Severity: Minor
          Found in web/src/lambda/login.ts - 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

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

          export const CartDrawer = () => {
            const lineItems = useCartItems()
            const { cartIsOpen } = useStore()
            const { total } = useCartTotals()
            const toggleCart = useToggleCart()
          Severity: Minor
          Found in web/src/components/cartDrawer.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

          Avoid too many return statements within this function.
          Open

              return statusReturn(500, { error: err.message })
          Severity: Major
          Found in web/src/lambda/login.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return statusReturn(500, { error: err.message })
            Severity: Major
            Found in web/src/lambda/reset-password.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                            return statusReturn(200, { error: 'Problem with mutation' })
              Severity: Major
              Found in web/src/lambda/shopify-sync.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                          return statusReturn(200, { body: 'nothing important changed' })
                Severity: Major
                Found in web/src/lambda/shopify-sync.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return statusReturn(200, { error: 'Problem looking up Product' })
                  Severity: Major
                  Found in web/src/lambda/shopify-sync.ts - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language