fbredius/storybook

View on GitHub

Showing 5,758 of 5,758 total issues

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

export const UndefinedNode = (props: object) => {
  const colors = useThemeColors();
  return (
    <span style={{ color: colors.nullish }} {...props}>
      undefined
Severity: Major
Found in addons/interactions/src/components/MethodCall.tsx and 1 other location - About 1 hr to fix
addons/interactions/src/components/MethodCall.tsx on lines 140..147

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

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

export const NullNode = (props: object) => {
  const colors = useThemeColors();
  return (
    <span style={{ color: colors.nullish }} {...props}>
      null
Severity: Major
Found in addons/interactions/src/components/MethodCall.tsx and 1 other location - About 1 hr to fix
addons/interactions/src/components/MethodCall.tsx on lines 149..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 64.

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 (!global.FEATURES?.modernInlineRender) {
        this.channel.off(Events.UPDATE_GLOBALS, render);
        this.channel.off(Events.UPDATE_STORY_ARGS, render);
        this.channel.off(Events.RESET_STORY_ARGS, render);
      }
Severity: Major
Found in lib/preview-web/src/PreviewWeb.tsx and 1 other location - About 1 hr to fix
lib/preview-web/src/PreviewWeb.tsx on lines 541..545

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

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

function parseIdentifier(identifierNode: estree.Identifier): ParsingResult<InspectionIdentifier> {
  return {
    inferredType: {
      type: InspectionType.IDENTIFIER,
      identifier: extractIdentifierName(identifierNode),
addons/docs/src/frameworks/react/lib/inspection/acornParser.ts on lines 169..174

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

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 findExportsMap has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function findExportsMap(ast) {
  const addsMap = {};
  estraverse.traverse(ast, {
    fallback: 'iteration',
    enter: (node, parent) => {
Severity: Minor
Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 1 hr to fix

    Function registerShortcuts has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const registerShortcuts = async (api: API, setState: any, viewportsKeys: string[]) => {
      await api.setAddonShortcut(ADDON_ID, {
        label: 'Previous viewport',
        defaultShortcut: ['shift', 'V'],
        actionName: 'previous',
    Severity: Minor
    Found in addons/viewport/src/shortcuts.ts - About 1 hr to fix

      Function filterTabs has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function filterTabs(panels: Addon[], parameters: Record<string, any>) {
        const { previewTabs } = addons.getConfig();
        const parametersTabs = parameters ? parameters.previewTabs : undefined;
      
        if (previewTabs || parametersTabs) {
      Severity: Minor
      Found in lib/ui/src/components/preview/preview.tsx - About 1 hr to fix

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

          render() {
            const {
              handleCancel,
              onlyValue,
              addButtonElement,
        Severity: Minor
        Found in lib/components/src/controls/react-editable-json-tree/JsonNodes.tsx - About 1 hr to fix

          Function splitExports has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          export function splitExports(ast, source) {
            const parts = [];
            let lastIndex = 0;
          
            const includeExclude = findIncludeExclude(ast);
          Severity: Minor
          Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.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 inject has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          function inject(source, filepath, options = {}, log = (message) => {}) {
            const { injectDecorator = true, injectStoryParameters = false } = options;
            const obviouslyNotCode = ['md', 'txt', 'json'].includes(options.parser);
            let parser = null;
            try {
          Severity: Minor
          Found in lib/source-loader/src/abstract-syntax-tree/inject-decorator.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 generateTypeFromString has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          function generateTypeFromString(value: string, originalTypeName: string): TypeDef {
            const { inferredType, ast } = inspectValue(value);
            const { type } = inferredType;
          
            let short;
          Severity: Minor
          Found in addons/docs/src/frameworks/react/propTypes/createType.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 loadFromPath has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          function loadFromPath(babelConfigPath: string): TransformOptions {
            let config: TransformOptions;
            const error: {
              js?: Error;
              json?: Error;
          Severity: Minor
          Found in lib/core-common/src/utils/load-custom-babel-config.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 ArgSummary has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          const ArgSummary: FC<ArgSummaryProps> = ({ value, initialExpandedArgs }) => {
            const { summary, detail } = value;
          
            const [isOpen, setIsOpen] = useState(false);
            const [isExpanded, setIsExpanded] = useState(initialExpandedArgs || false);
          Severity: Minor
          Found in lib/components/src/blocks/ArgsTable/ArgValue.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 validateArgs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          const validateArgs = (key = '', value: unknown): boolean => {
            if (key === null) return false;
            if (key === '' || !VALIDATION_REGEXP.test(key)) return false;
            if (value === null || value === undefined) return true; // encoded as `!null` or `!undefined`
            if (value instanceof Date) return true; // encoded as modified ISO string
          Severity: Minor
          Found in lib/preview-web/src/parseArgsParam.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 inferControl has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          const inferControl = (argType: StrictInputType, name: string, matchers: ControlsMatchers): any => {
            const { type, options } = argType;
            if (!type && !options) {
              return undefined;
            }
          Severity: Minor
          Found in lib/store/src/inferControls.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 start has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          export const start: WebpackBuilder['start'] = async ({ startTime, options, router }) => {
            const prebuiltDir = await getPrebuiltDir(options);
            if (prebuiltDir && options.managerCache && !options.smokeTest) {
              logger.info('=> Using prebuilt manager');
              router.use('/', express.static(prebuiltDir));
          Severity: Minor
          Found in lib/manager-webpack4/src/index.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 splitExports has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function splitExports(ast, source) {
            const parts = [];
            let lastIndex = 0;
          
            const includeExclude = findIncludeExclude(ast);
          Severity: Minor
          Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 1 hr to fix

            Function getSourceProps has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const getSourceProps = (
              props: SourceProps,
              docsContext: DocsContextProps<any>,
              sourceContext: SourceContextProps
            ): PureSourceProps & SourceStateProps => {
            Severity: Minor
            Found in addons/docs/src/blocks/Source.tsx - About 1 hr to fix

              Function tabs has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const tabs = useMemo(() => {
                  const { passes, incomplete, violations } = results;
                  return [
                    {
                      label: <Violations>{violations.length} Violations</Violations>,
              Severity: Minor
              Found in addons/a11y/src/components/A11YPanel.tsx - About 1 hr to fix

                Function Sidebar has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const Sidebar: FunctionComponent<{}> = React.memo(() => {
                  const mapper = ({ state, api }: Combo) => {
                    const {
                      ui: { name, url, enableShortcuts },
                      viewMode,
                Severity: Minor
                Found in lib/ui/src/containers/sidebar.tsx - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language