hack4impact/maps4all

View on GitHub

Showing 457 of 457 total issues

Avoid too many return statements within this function.
Open

    return render_template(
Severity: Major
Found in app/bulk_resource/views.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return render_template('bulk_resource/save.html', form=form)
    Severity: Major
    Found in app/bulk_resource/views.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return render_template('bulk_resource/set_descriptor_types.html',
      Severity: Major
      Found in app/bulk_resource/views.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return redirect(url_for('single_resource.index'))
        Severity: Major
        Found in app/bulk_resource/views.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return jsonify(redirect=url_for('bulk_resource.set_descriptor_types'))
          Severity: Major
          Found in app/bulk_resource/views.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return jsonify({
            Severity: Major
            Found in app/bulk_resource/views.py - About 30 mins to fix

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

                  try:
                      db.session.commit()
                      flash('Successfully deleted page', 'success')
                  except IntegrityError:
                      db.session.rollback()
              Severity: Minor
              Found in app/admin/views.py and 1 other location - About 30 mins to fix
              app/contact/views.py on lines 114..120

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

              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

                  try:
                      db.session.commit()
                      flash('Successfully deleted category \"%s\".' % category.name, 'success')
                  except IntegrityError:
                      db.session.rollback()
              Severity: Minor
              Found in app/contact/views.py and 1 other location - About 30 mins to fix
              app/admin/views.py on lines 268..274

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

              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 edit_option_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def edit_option_value(desc_id, option_index):
                  """Edit a descriptor's selected option value."""
                  descriptor = Descriptor.query.get(desc_id)
                  if descriptor is None:
                      abort(404)
              Severity: Minor
              Found in app/descriptor/views.py - About 25 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 login has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def login():
                  """Log in an existing user."""
                  form = LoginForm()
                  if form.validate_on_submit():
                      user = User.query.filter_by(email=form.email.data).first()
              Severity: Minor
              Found in app/account/views.py - About 25 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 makeResponsive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function makeResponsive() {
                setInitialZoom();
              
                // Change to a single column view
                if ($(window).width() <= singleColNoSpaceBreakpoint) {
              Severity: Minor
              Found in app/assets/scripts/map.js - About 25 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 edit_category_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def edit_category_name(category_id):
                  """Edit a category"""
                  category = ContactCategory.query.get(category_id)
                  if category is None:
                      abort(404)
              Severity: Minor
              Found in app/contact/views.py - About 25 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 add_new_options_from_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def add_new_options_from_string(self, new_options_string):
                      l = []
                      csv_reader = csv.reader(io.StringIO(new_options_string))
                      for row in csv_reader:
                          for option in row:
              Severity: Minor
              Found in app/models/bulk.py - About 25 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 get_associations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_associations(resource):
                      associations = {}
                      if resource is None:
                          return json.dumps(associations)
                      for td in resource.text_descriptors:
              Severity: Minor
              Found in app/models/resource.py - About 25 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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get(attr):
                      attribute = SiteAttribute.query.filter_by(attr_name=attr).first()
                      if attribute is None:
                          attribute = SiteAttribute(attr_name=attr)
                          if attr in os.environ:
              Severity: Minor
              Found in app/models/site_attribute.py - About 25 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 ratings_table has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def ratings_table():
                  """Ratings and Reviews Table."""
                  ratings = Rating.query.all()
                  for rating in ratings:
                      if rating.resource_id is not None:
              Severity: Minor
              Found in app/admin/views.py - About 25 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 get_resources_as_dicts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_resources_as_dicts(resources):
                      # get required option descriptor
                      req_opt_desc = RequiredOptionDescriptor.query.all()
                      if req_opt_desc:
                          req_opt_desc = req_opt_desc[0]
              Severity: Minor
              Found in app/models/resource.py - About 25 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