ikuseiGmbH/smart-village-app-cms

View on GitHub

Showing 1,158 of 1,254 total issues

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

class PointOfInterestsControllerTest < ActionDispatch::IntegrationTest
  test "should get index" do
    get point_of_interests_index_url
    assert_response :success
  end
Severity: Major
Found in test/controllers/point_of_interests_controller_test.rb and 3 other locations - About 1 hr to fix
test/controllers/events_controller_test.rb on lines 3..37
test/controllers/news_items_controller_test.rb on lines 3..37
test/controllers/tours_controller_test.rb on lines 3..37

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

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

class ToursControllerTest < ActionDispatch::IntegrationTest
  test "should get index" do
    get tours_index_url
    assert_response :success
  end
Severity: Major
Found in test/controllers/tours_controller_test.rb and 3 other locations - About 1 hr to fix
test/controllers/events_controller_test.rb on lines 3..37
test/controllers/news_items_controller_test.rb on lines 3..37
test/controllers/point_of_interests_controller_test.rb on lines 3..37

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

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

class EventsControllerTest < ActionDispatch::IntegrationTest
  test "should get index" do
    get events_index_url
    assert_response :success
  end
Severity: Major
Found in test/controllers/events_controller_test.rb and 3 other locations - About 1 hr to fix
test/controllers/news_items_controller_test.rb on lines 3..37
test/controllers/point_of_interests_controller_test.rb on lines 3..37
test/controllers/tours_controller_test.rb on lines 3..37

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

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

class NewsItemsControllerTest < ActionDispatch::IntegrationTest
  test "should get index" do
    get news_items_index_url
    assert_response :success
  end
Severity: Major
Found in test/controllers/news_items_controller_test.rb and 3 other locations - About 1 hr to fix
test/controllers/events_controller_test.rb on lines 3..37
test/controllers/point_of_interests_controller_test.rb on lines 3..37
test/controllers/tours_controller_test.rb on lines 3..37

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

Complex method User#sign_in (32.1)
Open

  def sign_in
    auth_server = SmartVillageApi.auth_server_url
    uri = Addressable::URI.parse("#{auth_server}/users/sign_in.json")
    result = ApiRequestService.new(uri.to_s, nil, nil, user_credentials).post_request
    if result.code == "200" && result.body.present?
Severity: Minor
Found in app/models/user.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

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

jsonform.fieldTemplate = function(inner) {
  return '<div ' +
    '<% for(var key in elt.htmlMetaData) {%>' +
      '<%= key %>="<%= elt.htmlMetaData[key] %>" ' +
    '<% }%>' +
Severity: Minor
Found in lib/jsonform.js - About 1 hr to fix

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

    jsonform.util.getObjKey = function (obj, key, ignoreArrays) {
      var innerobj = obj;
      var keyparts = key.split(".");
      var subkey = null;
      var arrayMatch = null;
    Severity: Minor
    Found in lib/jsonform.js - About 1 hr to fix

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

                formData.idx = (node.arrayPath.length > 0) ?
                  node.arrayPath[node.arrayPath.length-1] + 1 :
                  node.childPos + 1;
      Severity: Major
      Found in lib/jsonform.js and 1 other location - About 1 hr to fix
      lib/jsonform.js on lines 2782..2784

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

      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

                formData.idx = (node.arrayPath.length > 0) ?
                  node.arrayPath[node.arrayPath.length-1] + 1 :
                  node.childPos + 1;
      Severity: Major
      Found in lib/jsonform.js and 1 other location - About 1 hr to fix
      lib/jsonform.js on lines 2329..2331

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

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

          'onChange': function (evt, elt) {
            // The "transloadit" function should be called only once to enable
            // the service when the form is submitted. Has it already been done?
            if (elt.ownerTree._transloadit_bound) {
              return false;
      Severity: Minor
      Found in lib/jsonform.js - About 1 hr to fix

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

            var convertFormField = function (formField, splitPart, parentField) {
              var convertedField = null;
        
              var keepField = formField.root ||
                  (splitPart === 'all') ||
        Severity: Minor
        Found in lib/jsonform-split.js - About 1 hr to fix

          Method convert_params_for_graphql has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def convert_params_for_graphql
                # Convert date, as we always have and need exactly one
                if @survey_params["dates"].present?
                  dates = @survey_params.delete(:dates)
                  @survey_params["date"] = dates["0"]
          Severity: Minor
          Found in app/controllers/surveys_controller.rb - 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

          Method create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def create
              results = @smart_village.query <<~GRAPHQL
                query {
                  publicJsonFile(name: "wasteTypes", version: "1.0.0") {
                    content
          Severity: Minor
          Found in app/controllers/waste_calendar_controller.rb - 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 onChange has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              'onChange': function(evt,elt) {
                // The "transloadit" function should be called only once to enable
                // the service when the form is submitted. Has it already been done?
                if (elt.ownerTree._transloadit_bound) {
                  return false;
          Severity: Minor
          Found in lib/jsonform.js - About 1 hr to fix

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

                'onInsert': function (evt, node) {
                  $(node.el).on('click', '.dropdown-menu a', function (evt) {
                    evt.preventDefault();
                    evt.stopPropagation();
                    var img = (evt.target.nodeName.toLowerCase() === 'img') ?
            Severity: Minor
            Found in lib/jsonform.js - About 1 hr to fix

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

                  const initNestedScenes = ($form) => {
                    const timestamp = Date.now();
              
                    $form.find('.nested-tour-stop-scenes').addClass(`nested-tour-stop-scenes-${timestamp}`);
                    $form
              Severity: Minor
              Found in app/javascript/partials/_nested_tour_stop_form.js - About 1 hr to fix

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

                  $('#nested-categories').nestedForm({
                    forms: '.nested-category-form',
                    adder: '#nested-add-category',
                    ...defaultNestedFormsOptions,
                    beforeAddForm: ($container) => {
                Severity: Major
                Found in app/javascript/partials/_nested_forms.js and 4 other locations - About 1 hr to fix
                app/javascript/partials/_nested_forms.js on lines 42..49
                app/javascript/partials/_nested_forms.js on lines 51..58
                app/javascript/partials/_nested_forms.js on lines 60..67
                app/javascript/partials/_nested_forms.js on lines 69..76

                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

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

                  $('#nested-price_informations').nestedForm({
                    forms: '.nested-price_information-form',
                    adder: '#nested-add-price_information',
                    ...defaultNestedFormsOptions,
                    beforeAddForm: ($container) => {
                Severity: Major
                Found in app/javascript/partials/_nested_forms.js and 4 other locations - About 1 hr to fix
                app/javascript/partials/_nested_forms.js on lines 33..40
                app/javascript/partials/_nested_forms.js on lines 42..49
                app/javascript/partials/_nested_forms.js on lines 51..58
                app/javascript/partials/_nested_forms.js on lines 69..76

                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

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

                  $('#nested-dates').nestedForm({
                    forms: '.nested-date-form',
                    adder: '#nested-add-dates',
                    ...defaultNestedFormsOptions,
                    beforeAddForm: ($container) => {
                Severity: Major
                Found in app/javascript/partials/_nested_forms.js and 4 other locations - About 1 hr to fix
                app/javascript/partials/_nested_forms.js on lines 33..40
                app/javascript/partials/_nested_forms.js on lines 51..58
                app/javascript/partials/_nested_forms.js on lines 60..67
                app/javascript/partials/_nested_forms.js on lines 69..76

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

                formTree.prototype.initialize = function (formDesc) {
                  formDesc = formDesc || {};
                
                  // Keep a pointer to the initial JSONForm
                  // (note clone returns a shallow copy, only first-level is cloned)
                Severity: Minor
                Found in lib/jsonform.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language