Typeform/embed

View on GitHub

Showing 10 of 69 total issues

Function createPopup has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const createPopup = (formId: string, userOptions: PopupOptions): Popup => {
  if (!hasDom()) {
    return {
      open: () => {},
      close: () => {},
Severity: Major
Found in packages/embed/src/factories/create-popup/create-popup.ts - About 2 hrs to fix

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

    export const createSlider = (formId: string, userOptions: SliderOptions): Slider => {
      if (!hasDom()) {
        return {
          open: () => {},
          close: () => {},
    Severity: Major
    Found in packages/embed/src/factories/create-slider/create-slider.ts - About 2 hrs to fix

      Function createPopover has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const createPopover = (formId: string, userOptions: PopoverOptions = {}): Popover => {
        const options = { ...defaultOptions, ...userOptions }
        const iframe = createIframe(formId, 'popover', options)
      
        const popover = buildPopover()
      Severity: Major
      Found in packages/embed/src/factories/create-popover/create-popover.ts - About 2 hrs to fix

        Function createSidetab has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const createSidetab = (formId: string, userOptions: SidetabOptions = {}): Sidetab => {
          const options = { ...defaultOptions, ...userOptions }
          const iframe = createIframe(formId, 'side-tab', options)
        
          const sidetab = buildSidetab()
        Severity: Major
        Found in packages/embed/src/factories/create-sidetab/create-sidetab.ts - About 2 hrs to fix

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

          export default function Home() {
            const container = useRef();
          
            const widgetContainerStyle = {
              width: 500,
          Severity: Minor
          Found in packages/demo-nextjs/pages/index.js - About 1 hr to fix

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

            export const createPopup = (formId: string, userOptions: PopupOptions): Popup => {
              if (!hasDom()) {
                return {
                  open: () => {},
                  close: () => {},
            Severity: Minor
            Found in packages/embed/src/factories/create-popup/create-popup.ts - 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 Slider has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function Slider() {
              const openSlider = (position) => {
                createSlider("moe6aa", { position, medium: "demo-test" }).open();
              };
            
            
            Severity: Minor
            Found in packages/demo-nextjs/pages/slider.js - About 1 hr to fix

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

              export const createSidetab = (formId: string, userOptions: SidetabOptions = {}): Sidetab => {
                const options = { ...defaultOptions, ...userOptions }
                const iframe = createIframe(formId, 'side-tab', options)
              
                const sidetab = buildSidetab()
              Severity: Minor
              Found in packages/embed/src/factories/create-sidetab/create-sidetab.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

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

              export const createSlider = (formId: string, userOptions: SliderOptions): Slider => {
                if (!hasDom()) {
                  return {
                    open: () => {},
                    close: () => {},
              Severity: Minor
              Found in packages/embed/src/factories/create-slider/create-slider.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

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

              export const createPopover = (formId: string, userOptions: PopoverOptions = {}): Popover => {
                const options = { ...defaultOptions, ...userOptions }
                const iframe = createIframe(formId, 'popover', options)
              
                const popover = buildPopover()
              Severity: Minor
              Found in packages/embed/src/factories/create-popover/create-popover.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

              Severity
              Category
              Status
              Source
              Language