uchicago-sg/caravel

View on GitHub

Showing 17 of 21 total issues

Function matching has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def matching(klass, query, offset=0, limit=None):
        """Returns entities matching the given search query."""

        # Check contents of cache.
        words = tokenize(query)
Severity: Minor
Found in caravel/model/full_text.py - About 3 hrs 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 automod has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def automod():
    pending = itertools.chain(
        model.UnapprovedListing().query(),
        model.UnapprovedInquiry().query(),
    )
Severity: Minor
Found in caravel/controllers/moderation.py - 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 enableModeration has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var enableModeration = function(csrfToken) {
    var buttons = document.querySelectorAll(
      "[data-skip],[data-approve],[data-deny]");
    
    var siblingWithChildren = function(x) {
Severity: Minor
Found in caravel/static/js/moderation.js - About 1 hr to fix

    Function moderation_view has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def moderation_view():
        """
        Approves or denies a listing or inquiry.
        """
    
    
    Severity: Minor
    Found in caravel/controllers/moderation.py - 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 show_listing has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def show_listing(listing):
        """
        Retrieves a listing and displays it in the interface.
        """
    
    
    Severity: Minor
    Found in caravel/controllers/listings.py - About 55 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 _send_raw_mail has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def _send_raw_mail(to, subject, html, text, reply_to=None, sender=SENDER):
    Severity: Minor
    Found in caravel/utils/emails.py - About 45 mins to fix

      Function approved has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def approved(self):
              """
              Ensure that listings must be manually approved.
              """
      
      
      Severity: Minor
      Found in caravel/model/rate_limits.py - About 45 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 __call__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, **kwargs):
              """Renders a control with a Sign In button."""
      
              if users.get_current_user():
                  kwargs["type"] = "hidden"
      Severity: Minor
      Found in caravel/controllers/custom_fields.py - About 45 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 send_mail has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def send_mail(to, subject, html, text, reply_to=None, sender=SENDER):
      Severity: Minor
      Found in caravel/utils/emails.py - About 45 mins to fix

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

        var fetchMore = coalesce(function(complete) {
        
            var parameterString = window.location.search.substring(1);
            var continuation = "&continuation&offset=" + document.querySelectorAll(".listing").length;
        
        
        Severity: Minor
        Found in caravel/static/js/continuation.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

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

        def send_mail(to, subject, html, text, reply_to=None, sender=SENDER):
            """
            Sends an email to the given principals.
            """
        
        
        Severity: Minor
        Found in caravel/utils/emails.py - 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

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

            def process_formdata(self, values):
                """Process an external photo value."""
        
                for value in values:
                    if not value:
        Severity: Minor
        Found in caravel/controllers/custom_fields.py - 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

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

        def modify_search(add=[], remove=[]):
            """Adds and removes the given words from the query, returning the new ?q."""
        
            query = request.args.get('q', '').split()
            query = [x.strip() for x in query if x.strip()]
        Severity: Minor
        Found in caravel/controllers/listings.py - 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

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

        def get_keys(keys):
            """
            Fetch and save the given keys into memcache.
            """
        
        
        Severity: Minor
        Found in caravel/model/utils.py - 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

        Avoid too many return statements within this function.
        Open

                return False
        Severity: Major
        Found in caravel/model/rate_limits.py - About 30 mins to fix

          Function __call__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def __call__(self, form, field):
                  """Ensure that only the given user is used for authentication."""
          
                  if not self.principal:
                      raise Exception("No principal specified.")
          Severity: Minor
          Found in caravel/controllers/custom_fields.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 api_all_listings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def api_all_listings():
              """Display a list of listings that match the given query."""
          
              # Parse filtering options from query.
              query = request.args.get("q", "")
          Severity: Minor
          Found in caravel/controllers/api.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