dopry/netlify-cms

View on GitHub

Showing 220 of 220 total issues

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

  author: {
    type: 'string',
    secondaryTypes: [],
    synonyms: ['author', 'name', 'by', 'byline', 'owner'],
    defaultPreview: value => <strong>{ value }</strong>,
Severity: Major
Found in src/constants/fieldInference.js and 1 other location - About 1 hr to fix
src/constants/fieldInference.js on lines 5..12

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

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 inferWidget has 31 lines of code (exceeds 25 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

    Function persistEntry has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function persistEntry(collection) {
      return (dispatch, getState) => {
        const state = getState();
        const entryDraft = state.entryDraft;
    
    
    Severity: Minor
    Found in src/actions/entries.js - About 1 hr to fix

      Function persistUnpublishedEntry has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {
        return (dispatch, getState) => {
          const state = getState();
          const entryDraft = state.entryDraft;
      
      
      Severity: Minor
      Found in src/actions/editorialWorkflow.js - About 1 hr to fix

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

          render() {
            const { processing } = this.state;
            const imageName = this.renderImageName();
            if (processing) {
              return (
        Severity: Minor
        Found in src/components/Widgets/ImageControl.js - About 1 hr to fix

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

                this.promise = createAssetProxy(file.name, file, false, this.props.field.get('private', false))
                .then((assetProxy) => {
                  this.setState({ processing: false });
                  this.props.onAddAsset(assetProxy);
                  this.props.onChange(assetProxy.public_path);
          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 61..66

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

          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

                this.promise = createAssetProxy(file.name, file)
                .then((assetProxy) => {
                  this.setState({ processing: false });
                  this.props.onAddAsset(assetProxy);
                  this.props.onChange(assetProxy.public_path);
          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 57..62

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

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

            renderCard(collection, entry, inferedFields, publicFolder) {
              const path = `/collections/${ collection.get('name') }/entries/${ entry.get('slug') }`;
              const label = entry.get('label');
              const title = label || entry.getIn(['data', inferedFields.titleField]);
              let image = entry.getIn(['data', inferedFields.imageField]);
          Severity: Minor
          Found in src/components/EntryListing/EntryListing.js - About 1 hr to fix

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

              render() {
                const { processing } = this.state;
                const fileName = this.renderFileName();
                if (processing) {
                  return (
            Severity: Minor
            Found in src/components/Widgets/FileControl.js - About 1 hr to fix

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

                render() {
                  const { entry, collection } = this.props;
              
                  if (!entry || !entry.get('data')) {
                    return null;
              Severity: Minor
              Found in src/components/PreviewPane/PreviewPane.js - About 1 hr to fix

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

                const BackspaceCloseBlock = (options = {}) => ({
                  onKeyDown(e, data, state) {
                    if (data.key != 'backspace') return;
                
                    const { defaultBlock = 'paragraph', ignoreIn, onlyIn } = options;

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

                export default function remarkSquashReferences() {
                  return getTransform;
                
                  function getTransform(node) {
                    const getDefinition = mdastDefinitions(node);

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

                  render() {
                    const { onChange, onAddAsset, onRemoveAsset, getAsset, value } = this.props;
                    const { mode } = this.state;
                    const visualEditor = (
                      <div className="cms-editor-visual">
                Severity: Minor
                Found in src/components/Widgets/Markdown/MarkdownControl/index.js - About 1 hr to fix

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

                    render() {
                      const { plugins, onComponentMenuItemClick, disabled } = this.props;
                      return (
                        <div className={styles.root}>
                          <ToolbarButton

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

                        const {
                          user,
                          config,
                          children,
                          collections,
                    Severity: Major
                    Found in src/containers/App.js and 1 other location - About 1 hr to fix
                    src/reducers/index.js on lines 13..25

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

                    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 reducers = {
                      auth,
                      config,
                      collections,
                      search,
                    Severity: Major
                    Found in src/reducers/index.js and 1 other location - About 1 hr to fix
                    src/containers/App.js on lines 105..117

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

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

                      render() {
                        const { props, state } = this;
                        const stickyPlaceholderHeight = state.shouldStick ? this.ref.getBoundingClientRect().height : 0;
                    
                        return (
                    Severity: Minor
                    Found in src/components/UI/Sticky/Sticky.js - About 1 hr to fix

                      Function slugFormatter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const slugFormatter = (template = "{{slug}}", entryData) => {
                        const date = new Date();
                      
                        const getIdentifier = (entryData) => {
                          const validIdentifierFields = ["title", "path"];
                      Severity: Minor
                      Found in src/backends/backend.js - About 1 hr to fix

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

                          authenticate(user) {
                            this.tokenPromise = user.jwt.bind(user);
                            return this.tokenPromise()
                            .then((token) => {
                              let validRole = true;
                        Severity: Minor
                        Found in src/backends/git-gateway/implementation.js - About 1 hr to fix

                          Consider simplifying this complex logical expression.
                          Open

                              if (isRequired && (
                                value === null ||
                                value === undefined ||
                                (value.hasOwnProperty('length') && value.length === 0) ||
                                (value.constructor === Object && Object.keys(value).length === 0)
                          Severity: Major
                          Found in src/components/Widgets/ControlHOC.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language