tomi77/node-bookshelf-django

View on GitHub

Showing 13 of 13 total issues

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

module.exports = function(bookshelf) {
  if (bookshelf.model('Django.Site') == null) {
    bookshelf.model('Django.Site', {
      tableName: 'django_site',

Severity: Major
Found in models/django_site.js and 1 other location - About 6 hrs to fix
models/django_session.js on lines 1..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 157.

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(bookshelf) {
  if (bookshelf.model('Django.Session') == null) {
    bookshelf.model('Django.Session', {
      tableName: 'django_session',

Severity: Major
Found in models/django_session.js and 1 other location - About 6 hrs to fix
models/django_site.js on lines 1..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 157.

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

  if (!await knex.schema.hasTable('auth_user_groups')) {
    await knex.schema.createTable('auth_user_groups', function(table) {
      table.increments().primary();
      table.integer('user_id').notNullable().references('auth_user.id');
      table.integer('group_id').notNullable().references('auth_group.id');
Severity: Major
Found in migrations/00_initial.js and 3 other locations - About 5 hrs to fix
migrations/00_initial.js on lines 29..38
migrations/00_initial.js on lines 73..82
migrations/00_initial.js on lines 108..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 152.

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

  if (!await knex.schema.hasTable('auth_user_user_permissions')) {
    await knex.schema.createTable('auth_user_user_permissions', function(table) {
      table.increments().primary();
      table.integer('user_id').notNullable().references('auth_user.id');
      table.integer('permission_id').notNullable().references('auth_permission.id');
Severity: Major
Found in migrations/00_initial.js and 3 other locations - About 5 hrs to fix
migrations/00_initial.js on lines 29..38
migrations/00_initial.js on lines 73..82
migrations/00_initial.js on lines 98..107

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

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

  if (!await knex.schema.hasTable('django_flatpage_sites')) {
    await knex.schema.createTable('django_flatpage_sites', function(table) {
      table.increments().primary();
      table.integer('flatpage_id').notNullable().references('django_flatpage.id');
      table.integer('site_id').notNullable().references('django_site.id');
Severity: Major
Found in migrations/00_initial.js and 3 other locations - About 5 hrs to fix
migrations/00_initial.js on lines 73..82
migrations/00_initial.js on lines 98..107
migrations/00_initial.js on lines 108..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 152.

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

  if (!await knex.schema.hasTable('auth_group_permissions')) {
    await knex.schema.createTable('auth_group_permissions', function(table) {
      table.increments().primary();
      table.integer('group_id').notNullable().references('auth_group.id');
      table.integer('permission_id').notNullable().references('auth_permission.id');
Severity: Major
Found in migrations/00_initial.js and 3 other locations - About 5 hrs to fix
migrations/00_initial.js on lines 29..38
migrations/00_initial.js on lines 98..107
migrations/00_initial.js on lines 108..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 152.

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

exports.up = async (knex, Promise) => {
  if (!await knex.schema.hasTable('django_content_type')) {
    await knex.schema.createTable('django_content_type', function(table) {
      table.increments().primary();
      table.string('app_label', 100).notNullable();
Severity: Major
Found in migrations/00_initial.js - About 4 hrs to fix

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

    module.exports = function(bookshelf) {
      if (bookshelf.model('Django.Auth.User') == null) {
        require('./auth_permission')(bookshelf);
        require('./auth_group')(bookshelf);
    
    
    Severity: Minor
    Found in models/auth_user.js - About 1 hr to fix

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

      exports.up = async (knex, Promise) => {
        if (!await knex.schema.hasTable('django_content_type')) {
          await knex.schema.createTable('django_content_type', function(table) {
            table.increments().primary();
            table.string('app_label', 100).notNullable();
      Severity: Minor
      Found in migrations/00_initial.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 exports has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function(bookshelf) {
        if (bookshelf.model('Django.Auth.Group') == null) {
          require('./auth_permission')(bookshelf);
      
          bookshelf.model('Django.Auth.Group', {
      Severity: Minor
      Found in models/auth_group.js - About 1 hr to fix

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

        module.exports = function(bookshelf) {
          if (bookshelf.model('Django.Auth.Permission') == null) {
            require('./django_content_type')(bookshelf);
        
            bookshelf.model('Django.Auth.Permission', {
        Severity: Minor
        Found in models/auth_permission.js - About 1 hr to fix

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

          module.exports = function(bookshelf) {
            require('./models/django_session')(bookshelf);
            require('./models/django_site')(bookshelf);
            require('./models/django_flatpage')(bookshelf);
            require('./models/django_redirect')(bookshelf);
          Severity: Minor
          Found in index.js - About 1 hr to fix

            Function exports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports = function(bookshelf) {
              if (bookshelf.model('Django.Auth.User') == null) {
                require('./auth_permission')(bookshelf);
                require('./auth_group')(bookshelf);
            
            
            Severity: Minor
            Found in models/auth_user.js - About 35 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