dopry/netlify-cms

View on GitHub

Showing 220 of 220 total issues

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

  render() {
    const { onAddAsset, onRemoveAsset, getAsset } = this.props;

    return (
      <div className={styles.wrapper}>

    Function onKeyDown has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function onKeyDown(e, data, state) {
      const createDefaultBlock = () => {
        return Block.create({
          type: 'paragraph',
          nodes: [Text.createFromString('')]

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

            it('should render code', () => {
              const value = 'Use the `printf()` function.';
              const component = shallow(<MarkdownPreview value={markdownToHtml(value)} />);
              expect(component.html()).toMatchSnapshot();
            });
      src/components/Widgets/Markdown/MarkdownPreview/__tests__/renderer.spec.js on lines 95..99
      src/components/Widgets/Markdown/MarkdownPreview/__tests__/renderer.spec.js on lines 126..130

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

      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

          it('should render HTML', () => {
            const value = '<p>Paragraph with <em>inline</em> element</p>';
            const component = shallow(<MarkdownPreview value={markdownToHtml(value)} />);
            expect(component.html()).toMatchSnapshot();
          });
      src/components/Widgets/Markdown/MarkdownPreview/__tests__/renderer.spec.js on lines 89..93
      src/components/Widgets/Markdown/MarkdownPreview/__tests__/renderer.spec.js on lines 95..99

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

      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

            it('should render code 2', () => {
              const value = '``There is a literal backtick (`) here.``';
              const component = shallow(<MarkdownPreview value={markdownToHtml(value)} />);
              expect(component.html()).toMatchSnapshot();
            });
      src/components/Widgets/Markdown/MarkdownPreview/__tests__/renderer.spec.js on lines 89..93
      src/components/Widgets/Markdown/MarkdownPreview/__tests__/renderer.spec.js on lines 126..130

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

      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

          it('should set publish_mode from config', () => {
            expect(applyDefaults({
              foo: 'bar',
              publish_mode: 'complex',
              media_folder: 'path/to/media',
      Severity: Major
      Found in src/actions/__tests__/config.spec.js and 1 other location - About 1 hr to fix
      src/actions/__tests__/config.spec.js on lines 42..53

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

      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

          it('should not overwrite public_folder if set', () => {
            expect(applyDefaults({
              foo: 'bar',
              media_folder: 'path/to/media',
              public_folder: '/publib/path',
      Severity: Major
      Found in src/actions/__tests__/config.spec.js and 1 other location - About 1 hr to fix
      src/actions/__tests__/config.spec.js on lines 17..28

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

      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

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

              return this.getBranch()
              .then(branchData => this.updateTree(branchData.commit.sha, "/", fileTree))
              .then(changeTree => this.commit(options.commitMessage, changeTree))
              .then(response => this.patchBranch(this.branch, response.sha));
      Severity: Major
      Found in src/backends/github/API.js and 1 other location - About 1 hr to fix
      src/backends/github/API.js on lines 300..303

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

      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

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

            return this.getBranch()
            .then(branchData => this.updateTree(branchData.commit.sha, "/", fileTree))
            .then(changeTree => this.commit(options.commitMessage, changeTree))
            .then(commitResponse => this.createBranch(branchName, commitResponse.sha))
      Severity: Major
      Found in src/backends/github/API.js and 1 other location - About 1 hr to fix
      src/backends/github/API.js on lines 263..266

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

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

      const entries = (state = defaultState, action) => {
        switch (action.type) {
          case SEARCH_CLEAR:
            return defaultState;
      
      
      Severity: Minor
      Found in src/reducers/search.js - About 1 hr to fix

        Function remarkPaddedLinks has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function remarkPaddedLinks() {
        
          function transform(node) {
        
            /**
        Severity: Minor
        Found in src/components/Widgets/Markdown/serializers/remarkPaddedLinks.js - About 1 hr to fix

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

              if (processing) {
                return (
                  <div className={styles.imageUpload}>
                    <span className={styles.message}>
                      <Loader active />
          Severity: Major
          Found in src/components/Widgets/FileControl.js and 1 other location - About 1 hr to fix
          src/components/Widgets/ImageControl.js on lines 84..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 67.

          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 (processing) {
                return (
                  <div className={styles.imageUpload}>
                    <span className={styles.message}>
                      <Loader active />
          Severity: Major
          Found in src/components/Widgets/ImageControl.js and 1 other location - About 1 hr to fix
          src/components/Widgets/FileControl.js on lines 80..88

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

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

          const sortKeys = (sortedKeys = []) => (a, b) => {
            const idxA = sortedKeys.indexOf(a);
            const idxB = sortedKeys.indexOf(b);
            if (idxA === -1 || idxB === -1) {
              if (a > b) return 1;
          Severity: Minor
          Found in src/formats/yaml.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 processCollection has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function processCollection(collection, collectionKey) {
                const state = getState();
                if (state.entries.hasIn(['pages', collectionKey, 'ids'])) {
                  const searchFields = [
                    selectInferedField(collection, 'title'),
          Severity: Minor
          Found in src/actions/search.js - About 1 hr to fix

            Function EntryPageHOC has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function EntryPageHOC(EntryPage) {
              class EntryPageHOC extends React.Component {
                render() {
                  return <EntryPage {...this.props} />;
                }
            Severity: Minor
            Found in src/containers/editorialWorkflow/EntryPageHOC.js - About 1 hr to fix

              Function remarkUnwrapInvalidNest has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function remarkUnwrapInvalidNest() {
                return transform;
              
                function transform(tree) {
                  const invalidNest = findInvalidNest(tree);
              Severity: Minor
              Found in src/components/Widgets/Markdown/serializers/remarkAssertParents.js - About 1 hr to fix

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

                  render() {
                    const {
                      entry,
                      entryDraft,
                      fields,
                Severity: Minor
                Found in src/containers/EntryPage.js - About 1 hr to fix

                  Function authenticate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    authenticate(options, cb) {
                      var left, top, url,
                        siteID = this.getSiteID(),
                        provider = options.provider;
                      if (!provider) {
                  Severity: Minor
                  Found in src/lib/netlify-auth.js - About 1 hr to fix

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

                        case ENTRY_SUCCESS:
                          return state.setIn(
                            ['entities', `${ action.payload.collection }.${ action.payload.entry.slug }`],
                            fromJS(action.payload.entry)
                          );
                    Severity: Major
                    Found in src/reducers/entries.js and 1 other location - About 1 hr to fix
                    src/reducers/editorialWorkflow.js on lines 32..36

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language