dopry/netlify-cms

View on GitHub

Showing 220 of 220 total issues

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

function unpublishedEntryStatusChangePersisted(collection, slug, oldStatus, newStatus, transactionID) {
  return {
    type: UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS,
    payload: { 
      collection,
Severity: Major
Found in src/actions/editorialWorkflow.js and 1 other location - About 1 hr to fix
src/actions/editorialWorkflow.js on lines 126..137

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

    it('should set public_folder based on media_folder if not set', () => {
      expect(applyDefaults({
        foo: 'bar',
        media_folder: 'path/to/media',
      })).toEqual({
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 5..15

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

    it('should set publish_mode if not set', () => {
      expect(applyDefaults({
        foo: 'bar',
        media_folder: 'path/to/media',
      })).toEqual({
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 30..40

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

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

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 unpublishedEntryStatusChangeRequest(collection, slug, oldStatus, newStatus, transactionID) {
  return {
    type: UNPUBLISHED_ENTRY_STATUS_CHANGE_REQUEST,
    payload: { 
      collection,
Severity: Major
Found in src/actions/editorialWorkflow.js and 1 other location - About 1 hr to fix
src/actions/editorialWorkflow.js on lines 139..150

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

  upload(file, privateUpload = false) {
    const fileData = {
      name: file.name,
      size: file.size
    };
Severity: Minor
Found in src/integrations/providers/assetStore/implementation.js - About 1 hr to fix

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

      unpublishedEntries() {
        return this.api.listUnpublishedBranches().then((branches) => {
          const sem = semaphore(MAX_CONCURRENT_DOWNLOADS);
          const promises = [];
          branches.map((branch) => {
    Severity: Minor
    Found in src/backends/github/implementation.js - About 1 hr to fix

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

        render() {
          const {
            plugin,
            onSubmit,
            onCancel,

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

          persistEntry(config, collection, entryDraft, MediaFiles, options) {
            const newEntry = entryDraft.getIn(["entry", "newRecord"]) || false;
        
            const parsedData = {
              title: entryDraft.getIn(["entry", "data", "title"], "No Title"),
        Severity: Minor
        Found in src/backends/backend.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

              if (!unpublished) {
                // Open new editorial review workflow for this entry - Create new metadata and commit to new branch`
                const contentKey = entry.slug;
                const branchName = `cms/${ contentKey }`;
          
          
          Severity: Critical
          Found in src/backends/github/API.js - About 1 hr to fix

            Function updateTree has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              updateTree(sha, path, fileTree) {
                return this.getTree(sha)
                  .then((tree) => {
                    let obj;
                    let filename;
            Severity: Minor
            Found in src/backends/github/API.js - About 1 hr to fix

              Function controlFor has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                controlFor(field) {
                  const { entry, fieldsMetaData, fieldsErrors, getAsset, onChange, onAddAsset, onRemoveAsset } = this.props;
                  const widget = resolveWidget(field.get('widget'));
                  const fieldName = field.get('name');
                  const value = entry.getIn(['data', fieldName]);
              Severity: Minor
              Found in src/components/ControlPanel/ControlPane.js - About 1 hr to fix

                Function renderItem has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  renderItem(item, index) {
                    const { value, field, getAsset, onAddAsset, onRemoveAsset } = this.props;
                    const { itemStates } = this.state;
                    const collapsed = itemStates.getIn([index, 'collapsed']);
                    const classNames = [styles.item, collapsed ? styles.collapsed : styles.expanded];
                Severity: Minor
                Found in src/components/Widgets/ListControl.js - About 1 hr to fix

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

                    parseJsonResponse(response) {
                      return response.json().then((json) => {
                        if (!response.ok) {
                          return Promise.reject(json);
                        }
                  Severity: Major
                  Found in src/integrations/providers/assetStore/implementation.js and 2 other locations - About 1 hr to fix
                  src/backends/github/API.js on lines 45..53
                  src/integrations/providers/algolia/implementation.js on lines 41..49

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

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

                    parseJsonResponse(response) {
                      return response.json().then((json) => {
                        if (!response.ok) {
                          return Promise.reject(json);
                        }
                  Severity: Major
                  Found in src/backends/github/API.js and 2 other locations - About 1 hr to fix
                  src/integrations/providers/algolia/implementation.js on lines 41..49
                  src/integrations/providers/assetStore/implementation.js on lines 13..21

                  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

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

                    parseJsonResponse(response) {
                      return response.json().then((json) => {
                        if (!response.ok) {
                          return Promise.reject(json);
                        }
                  Severity: Major
                  Found in src/integrations/providers/algolia/implementation.js and 2 other locations - About 1 hr to fix
                  src/backends/github/API.js on lines 45..53
                  src/integrations/providers/assetStore/implementation.js on lines 13..21

                  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

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

                  function unpublishedEntryPersisted(collection, entry, transactionID) {
                    return {
                      type: UNPUBLISHED_ENTRY_PERSIST_SUCCESS,
                      payload: { 
                        collection: collection.get('name'),
                  Severity: Major
                  Found in src/actions/editorialWorkflow.js and 1 other location - About 1 hr to fix
                  src/actions/editorialWorkflow.js on lines 96..105

                  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

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

                  function unpublishedEntryPersisting(collection, entry, transactionID) {
                    return {
                      type: UNPUBLISHED_ENTRY_PERSIST_REQUEST,
                      payload: {
                        collection: collection.get('name'),
                  Severity: Major
                  Found in src/actions/editorialWorkflow.js and 1 other location - About 1 hr to fix
                  src/actions/editorialWorkflow.js on lines 107..116

                  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

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

                    title: {
                      type: 'string',
                      secondaryTypes: [],
                      synonyms: ['title', 'name', 'label', 'headline', 'header'],
                      defaultPreview: value => <h1>{ value }</h1>,
                  Severity: Major
                  Found in src/constants/fieldInference.js and 1 other location - About 1 hr to fix
                  src/constants/fieldInference.js on lines 21..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 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

                  Severity
                  Category
                  Status
                  Source
                  Language