makeomatic/mservice-calendar

View on GitHub

Showing 22 of 22 total issues

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

module.exports = function postSubscribe(params, user) {
  const { fcmToken } = params;
  if (fcmToken) {
    const { config } = this;
    const { firebase: { adminCert, messaging: { topic: { eventPrefix } } } } = config;
Severity: Major
Found in src/custom/rfx-post-unsubscribe.js and 1 other location - About 1 day to fix
src/custom/rfx-post-subscribe.js on lines 3..22

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

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

module.exports = function postSubscribe(params, user) {
  const { fcmToken } = params;
  if (fcmToken) {
    const { config } = this;
    const { firebase: { adminCert, messaging: { topic: { eventPrefix } } } } = config;
Severity: Major
Found in src/custom/rfx-post-subscribe.js and 1 other location - About 1 day to fix
src/custom/rfx-post-unsubscribe.js on lines 3..22

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

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 EventSubscribe({ params, auth }) {
  const { id } = params;
  const { user } = auth.credentials;

  return this
Severity: Major
Found in src/actions/event.subscribe.js and 1 other location - About 3 hrs to fix
src/actions/event.unsubscribe.js on lines 8..19

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

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 EventUnsubscribe({ params, auth }) {
  const { id } = params;
  const { user } = auth.credentials;

  return this
Severity: Major
Found in src/actions/event.unsubscribe.js and 1 other location - About 3 hrs to fix
src/actions/event.subscribe.js on lines 8..19

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

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

File storage.js has 278 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * services/storage.js
 */

const Promise = require('bluebird');
Severity: Minor
Found in src/services/storage.js - About 2 hrs to fix

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

        return yield Promise
          .bind(this.storage, data)
          .then(Event.parseRRule)
          .catch((e) => {
            throw new Errors.HttpStatusError(400, `Invalid RRule: ${e.message}`);
    Severity: Major
    Found in src/services/event.js and 1 other location - About 1 hr to fix
    src/services/event.js on lines 116..122

    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

        return yield Promise
          .bind(this.storage, event)
          .then(Event.parseRRule)
          .catch((e) => {
            throw new Errors.HttpStatusError(400, `Invalid RRule: ${e.message}`);
    Severity: Major
    Found in src/services/event.js and 1 other location - About 1 hr to fix
    src/services/event.js on lines 93..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 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

    Function getUploadTagsList has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const getUploadTagsList = (argv) => {
      const root = path.resolve(process.cwd(), argv.dir);
      const sections = glob.sync('*', { cwd: root });
    
      // gives complete list of section/genres
    Severity: Minor
    Found in bin/tags.js - About 1 hr to fix

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

        listEventSubs(filters) {
          let startTime = filters.startTime ? moment.utc(filters.startTime) : moment.utc();
          let endTime = filters.endTime ? moment.utc(filters.endTime) : moment.utc().add(1, 'years');
      
          startTime = startTime.toISOString();
      Severity: Minor
      Found in src/services/storage.js - About 1 hr to fix

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

          getEvents(filter) {
            const { owner, tags, hosts } = filter;
            const knex = this.client;
        
            const startTime = new Date(filter.startTime).toISOString();
        Severity: Minor
        Found in src/services/storage.js - About 1 hr to fix

          Function parseRRule has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            static parseRRule(data) {
              const opts = RRule.parseString(data.rrule);
              // const now = moment();
          
              // check frequency
          Severity: Minor
          Found in src/services/event.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 parseRRule has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            static parseRRule(data) {
              const opts = RRule.parseString(data.rrule);
              // const now = moment();
          
              // check frequency
          Severity: Minor
          Found in src/services/event.js - About 1 hr to fix

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

            function uploadFiles(argv) {
              // example:
              //  -x ~/projects/rfx-chef/cookbooks/rfx-docker/files/default/gce-key.json
              // eslint-disable-next-line import/no-dynamic-require
              const credentials = require(argv.credentials);
            Severity: Minor
            Found in bin/tags.js - About 1 hr to fix

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

                createEvent(data) {
                  // won't be more than 365 e vents due to constraints we have
                  const knex = this.client;
                  const resultingEvent = pick(data, EVENT_FIELDS);
              
              
              Severity: Minor
              Found in src/services/storage.js - About 1 hr to fix

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

                  getEventTags(filter) {
                    const knex = this.client;
                    const isActive = filter.active;
                    const startTime = filter.startTime || new Date().toISOString();
                    const endTime = filter.endTime || moment().add(2, 'month').toISOString();
                Severity: Minor
                Found in src/services/storage.js - About 1 hr to fix

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

                        query
                          .joinRaw(`INNER JOIN ${EVENT_TABLE} on ${EVENT_TABLE}.tags @> ARRAY[${EVENT_TAGS_TABLE}.id]`)
                          .joinRaw((`INNER JOIN ${EVENT_SPANS_TABLE} on (`
                            + `${EVENT_TABLE}.id = ${EVENT_SPANS_TABLE}.event_id AND `
                            + `${EVENT_SPANS_TABLE}.period && tsrange(TIMESTAMP '${startTime}', TIMESTAMP '${endTime}')`
                  Severity: Minor
                  Found in src/services/storage.js and 1 other location - About 55 mins to fix
                  src/services/storage.js on lines 195..213

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

                  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 query = knex
                        .select([
                          'id',
                          'title',
                          'description',
                  Severity: Minor
                  Found in src/services/storage.js and 1 other location - About 55 mins to fix
                  src/services/storage.js on lines 340..346

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

                  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 4 locations. Consider refactoring.
                  Open

                  exports.down = knex => (
                    knex.schema.table(EVENT_TABLE, (table) => {
                      table.dropColumn('version');
                    })
                  );
                  Severity: Major
                  Found in src/migrations/20181110001438_events.js and 3 other locations - About 30 mins to fix
                  src/migrations/20161121171335_events_spans.js on lines 10..14
                  src/migrations/20170328102926_events_tags.js on lines 13..17
                  src/migrations/20181101001438_events.js on lines 10..14

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

                  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 4 locations. Consider refactoring.
                  Open

                  exports.down = knex => (
                    knex.schema.table(EVENT_TAGS_TABLE, (table) => {
                      table.dropColumn('section');
                    })
                  );
                  Severity: Major
                  Found in src/migrations/20170328102926_events_tags.js and 3 other locations - About 30 mins to fix
                  src/migrations/20161121171335_events_spans.js on lines 10..14
                  src/migrations/20181101001438_events.js on lines 10..14
                  src/migrations/20181110001438_events.js on lines 10..14

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

                  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 4 locations. Consider refactoring.
                  Open

                  exports.down = knex => (
                    knex.schema.table(EVENT_SPANS_TABLE, (table) => {
                      table.dropColumn('owner');
                    })
                  );
                  Severity: Major
                  Found in src/migrations/20161121171335_events_spans.js and 3 other locations - About 30 mins to fix
                  src/migrations/20170328102926_events_tags.js on lines 13..17
                  src/migrations/20181101001438_events.js on lines 10..14
                  src/migrations/20181110001438_events.js on lines 10..14

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

                  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