dopry/netlify-cms

View on GitHub

Showing 220 of 220 total issues

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

  renderImageName = () => {
    if (!this.props.value) return null;
    if (this.value instanceof AssetProxy) {
      return truncateMiddle(this.props.value.path, MAX_DISPLAY_LENGTH);
    } else {
Severity: Major
Found in src/components/Widgets/ImageControl.js and 1 other location - About 2 hrs to fix
src/components/Widgets/FileControl.js on lines 68..75

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

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

  renderFileName = () => {
    if (!this.props.value) return null;
    if (this.value instanceof AssetProxy) {
      return truncateMiddle(this.props.value.path, MAX_DISPLAY_LENGTH);
    } else {
Severity: Major
Found in src/components/Widgets/FileControl.js and 1 other location - About 2 hrs to fix
src/components/Widgets/ImageControl.js on lines 72..79

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

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

const entryDraftReducer = (state = Map(), action) => {
  switch (action.type) {
    case DRAFT_CREATE_FROM_ENTRY:
      // Existing Entry
      return state.withMutations((state) => {
Severity: Major
Found in src/reducers/entryDraft.js - About 2 hrs to fix

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

    PreviewPane.propTypes = {
      collection: ImmutablePropTypes.map.isRequired,
      fields: ImmutablePropTypes.list.isRequired,
      entry: ImmutablePropTypes.map.isRequired,
      fieldsMetaData: ImmutablePropTypes.map.isRequired,
    Severity: Major
    Found in src/components/PreviewPane/PreviewPane.js and 1 other location - About 2 hrs to fix
    src/components/PreviewPane/Preview.js on lines 31..37

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

    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 visualEditor = (
          <div className="cms-editor-visual">
            <VisualEditor
              onChange={onChange}
              onAddAsset={onAddAsset}
    Severity: Major
    Found in src/components/Widgets/Markdown/MarkdownControl/index.js and 1 other location - About 2 hrs to fix
    src/components/Widgets/Markdown/MarkdownControl/index.js on lines 45..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 77.

    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 rawEditor = (
          <div className="cms-editor-raw">
            <RawEditor
              onChange={onChange}
              onAddAsset={onAddAsset}
    Severity: Major
    Found in src/components/Widgets/Markdown/MarkdownControl/index.js and 1 other location - About 2 hrs to fix
    src/components/Widgets/Markdown/MarkdownControl/index.js on lines 33..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 77.

    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

    Preview.propTypes = {
      collection: ImmutablePropTypes.map.isRequired,
      entry: ImmutablePropTypes.map.isRequired,
      fields: ImmutablePropTypes.list.isRequired,
      getAsset: PropTypes.func.isRequired,
    Severity: Major
    Found in src/components/PreviewPane/Preview.js and 1 other location - About 2 hrs to fix
    src/components/PreviewPane/PreviewPane.js on lines 161..167

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

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

    function onKeyDown(e, data, state) {
      const createDefaultBlock = () => {
        return Block.create({
          type: 'paragraph',
          nodes: [Text.createFromString('')]
    Severity: Minor
    Found in src/components/Widgets/Markdown/MarkdownControl/VisualEditor/keys.js - About 2 hrs 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 render has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        const {
          onToggleMode,
          rawMode,
          plugins,
    Severity: Major
    Found in src/components/Widgets/Markdown/MarkdownControl/Toolbar/Toolbar.js - About 2 hrs to fix

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

          const input = u('root', [
            u('blockquote', [
              u('list', [
                u('listItem', [
                  u('table', [
      src/components/Widgets/Markdown/serializers/__tests__/remarkAssertParents.spec.js on lines 186..200

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

      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 output = u('root', [
            u('blockquote', [
              u('list', [
                u('listItem', [
                  u('table', [
      src/components/Widgets/Markdown/serializers/__tests__/remarkAssertParents.spec.js on lines 170..184

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

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

      const unpublishedEntries = (state = null, action) => {
        const publishMode = action.payload && action.payload.publish_mode;
        switch (action.type) {
          case CONFIG_SUCCESS:
            if (publishMode === EDITORIAL_WORKFLOW) {
      Severity: Minor
      Found in src/reducers/editorialWorkflow.js - About 1 hr to fix

        Function SoftBreak has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        const SoftBreak = (options = {}) => ({
          onKeyDown(e, data, state) {
            if (data.key != 'enter') return;
            if (options.shift && e.shiftKey == false) 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 inferWidget has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function inferWidget(name, value) {
          if (value == null) {
            return { widget: 'string' };
          }
          if (value instanceof Date) {
        Severity: Minor
        Found in scripts/autoconfigure.collection.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 convertNode has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function convertNode(node, children, shortcodePlugins) {
          switch (node.type) {
        
            /**
             * General
        Severity: Minor
        Found in src/components/Widgets/Markdown/serializers/slateRemark.js - About 1 hr to fix

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

            render() {
              const { errors } = this.state;
              const { error } = this.props;
          
              if (window.netlifyIdentity) {
          Severity: Minor
          Found in src/backends/git-gateway/AuthenticationPage.js - About 1 hr to fix

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

              render() {
                const {
                  user,
                  collections,
                  runCommand,
            Severity: Minor
            Found in src/components/AppHeader/AppHeader.js - About 1 hr to fix

              Function localSearch has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function localSearch(searchTerm, getState, dispatch) {
                return (function acc(localResults = { entries: [] }) {
                  function processCollection(collection, collectionKey) {
                    const state = getState();
                    if (state.entries.hasIn(['pages', collectionKey, 'ids'])) {
              Severity: Minor
              Found in src/actions/search.js - About 1 hr to fix

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

                            <Input
                              type="text"
                              label="Email"
                              name="email"
                              value={this.state.email}
                Severity: Major
                Found in src/backends/git-gateway/AuthenticationPage.js and 1 other location - About 1 hr to fix
                src/backends/git-gateway/AuthenticationPage.js on lines 124..131

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

                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

                            <Input
                              type="password"
                              label="Password"
                              name="password"
                              value={this.state.password}
                Severity: Major
                Found in src/backends/git-gateway/AuthenticationPage.js and 1 other location - About 1 hr to fix
                src/backends/git-gateway/AuthenticationPage.js on lines 116..123

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

                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

                Severity
                Category
                Status
                Source
                Language