dopry/netlify-cms

View on GitHub

Showing 110 of 220 total issues

Function runSerializer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const runSerializer = (values, fields, method) => {

  /**
   * Reduce the list of fields to a map where keys are field names and values
   * are field values, serializing the values of fields whose widgets have
Severity: Minor
Found in src/lib/serializeEntryValues.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 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

          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

                    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

                            Function remarkImagesToText has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export default function remarkImagesToText() {
                              return transform;
                            
                              function transform(node) {
                                const children = node.children ? node.children.map(transform) : node.children;
                            Severity: Minor
                            Found in src/components/Widgets/Markdown/serializers/remarkImagesToText.js - About 55 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 waitUntilAction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export default function waitUntilAction({ dispatch, getState }) {
                              let pending = [];
                            
                              function checkPending(action) {
                                const readyRequests = [];
                            Severity: Minor
                            Found in src/redux/middleware/waitUntilAction.js - 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 integrations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const integrations = (state = null, action) => {
                              switch (action.type) {
                                case CONFIG_SUCCESS:
                                  const integrations = action.payload.integrations || [];
                                  const newState = integrations.reduce((acc, integration) => {
                            Severity: Minor
                            Found in src/reducers/integrations.js - 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 validateConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function validateConfig(config) {
                              if (!get(config, 'backend')) {
                                throw new Error("Error in configuration file: A `backend` wasn't found. Check your config.yml file.");
                              }
                              if (!get(config, ['backend', 'name'])) {
                            Severity: Minor
                            Found in src/actions/config.js - 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