adsabs/metrics_service

View on GitHub

Showing 18 of 90 total issues

File metrics.py has 570 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'''
Created on April 8, 2015

@author: ehenneken
'''
Severity: Major
Found in metrics_service/metrics.py - About 1 day to fix

    Consider simplifying this complex logical expression.
    Open

        if usage_type == 'reads':
            # Get all reads data and sum up the individual lists
            usage_data = [
                p.reads for p in data if p.reads and len(p.reads) == Nentries]
            usage = [sum(sublist)
    Severity: Critical
    Found in metrics_service/metrics.py - About 5 hrs to fix

      Function post has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          def post(self):
              bibcodes = []
              query = None
              stime = time.time()
              try:
      Severity: Minor
      Found in metrics_service/views.py - About 4 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 generate_metrics has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def generate_metrics(**args):
          result = {}
          usage_data = None
          citdata = None
          citlists = None
      Severity: Minor
      Found in metrics_service/metrics.py - About 2 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 get_usage_histograms has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_usage_histograms(identifiers, usage_type='reads', data=None):
          uh = {}
          # Get necessary data if nothing was provided
          if not data:
              data = get_usage_data(identifiers)
      Severity: Minor
      Found in metrics_service/metrics.py - About 2 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 get_time_series has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_time_series(identifiers, bibcodes, data=None, usagedata=None,
                          tori_data=None, include_tori=True, self_cits=None):
          series = {}
          i10 = {}
          i100 = {}
      Severity: Minor
      Found in metrics_service/metrics.py - About 2 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 get_citation_stats has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def get_citation_stats(identifiers, bibcodes, bibcodes_ref):
          data = selfcits = citdata = None
          # citation stats for all publications
          cs = {}
          # citation stats for refereed publications
      Severity: Minor
      Found in metrics_service/metrics.py - About 1 hr to fix

        Function get_indicators has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def get_indicators(identifiers, data=None, usagedata=None):
            ind = {}
            ind_ref = {}
            # Get the necessary data if we did not get any
            if not data:
        Severity: Minor
        Found in metrics_service/metrics.py - About 1 hr to fix

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

          def get_basic_stats(identifiers):
              # basic stats for all publications
              bs = {}
              # basic stats for refereed publications`
              bsr = {}
          Severity: Minor
          Found in metrics_service/metrics.py - About 1 hr to fix

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

            def get_citation_histograms(identifiers, data=None):
                ch = {}
                current_year = datetime.now().year
                # Get necessary data if nothing was provided
                if not data:
            Severity: Minor
            Found in metrics_service/metrics.py - About 1 hr to fix

              Function get_time_series has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def get_time_series(identifiers, bibcodes, data=None, usagedata=None,
                                  tori_data=None, include_tori=True, self_cits=None):
                  series = {}
                  i10 = {}
                  i100 = {}
              Severity: Minor
              Found in metrics_service/metrics.py - About 1 hr to fix

                Function get_time_series has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def get_time_series(identifiers, bibcodes, data=None, usagedata=None,
                Severity: Major
                Found in metrics_service/metrics.py - About 50 mins to fix

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

                      def post(self):
                          details = {}
                          details['skipped bibcodes'] = []
                          try:
                              bibcodes = list(map(str, request.json['bibcodes']))
                  Severity: Minor
                  Found in metrics_service/views.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 get_basic_stats has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def get_basic_stats(identifiers):
                      # basic stats for all publications
                      bs = {}
                      # basic stats for refereed publications`
                      bsr = {}
                  Severity: Minor
                  Found in metrics_service/metrics.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 results
                  Severity: Major
                  Found in metrics_service/views.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return results, 500
                    Severity: Major
                    Found in metrics_service/views.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                  return {'Error': 'Unable to get results!',
                      Severity: Major
                      Found in metrics_service/views.py - About 30 mins to fix

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

                        def get_indicators(identifiers, data=None, usagedata=None):
                            ind = {}
                            ind_ref = {}
                            # Get the necessary data if we did not get any
                            if not data:
                        Severity: Minor
                        Found in metrics_service/metrics.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