rmosolgo/graphql-ruby

View on GitHub
lib/graphql/language/printer.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Printer has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Printer
      # Turn an arbitrary AST node back into a string.
      #
      # @example Turning a document into a query string
      #    document = GraphQL.parse(query_string)
Severity: Minor
Found in lib/graphql/language/printer.rb - About 4 hrs to fix

    File printer.rb has 293 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module GraphQL
      module Language
        class Printer
          # Turn an arbitrary AST node back into a string.
          #
    Severity: Minor
    Found in lib/graphql/language/printer.rb - About 3 hrs to fix

      Method print_node has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def print_node(node, indent: "")
              case node
              when Nodes::Document
                print_document(node)
              when Nodes::Argument
      Severity: Major
      Found in lib/graphql/language/printer.rb - About 2 hrs to fix

        Method print_schema_definition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def print_schema_definition(schema)
                if (schema.query.nil? || schema.query == 'Query') &&
                   (schema.mutation.nil? || schema.mutation == 'Mutation') &&
                   (schema.subscription.nil? || schema.subscription == 'Subscription') &&
                   (schema.directives.empty?)
        Severity: Minor
        Found in lib/graphql/language/printer.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

        Consider simplifying this complex logical expression.
        Open

                if (schema.query.nil? || schema.query == 'Query') &&
                   (schema.mutation.nil? || schema.mutation == 'Mutation') &&
                   (schema.subscription.nil? || schema.subscription == 'Subscription') &&
                   (schema.directives.empty?)
                  return
        Severity: Major
        Found in lib/graphql/language/printer.rb - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status