prawnpdf/prawn

View on GitHub
lib/prawn/font/ttf.rb

Summary

Maintainability
C
1 day
Test Coverage

Class TTF has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

    class TTF < Font
      attr_reader :ttf, :subsets

      def unicode?
        true
Severity: Minor
Found in lib/prawn/font/ttf.rb - About 3 hrs to fix

    Method encode_text has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

          def encode_text(text, options = {})
            text = text.chomp
    
            if options[:kerning]
              last_subset = nil
    Severity: Minor
    Found in lib/prawn/font/ttf.rb - 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

    File ttf.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'ttfunk'
    require 'ttfunk/subset_collection'
    
    module Prawn
      class Font
    Severity: Minor
    Found in lib/prawn/font/ttf.rb - About 2 hrs to fix

      Method embed has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def embed(reference, subset)
              font_content = @subsets[subset].encode
      
              # FIXME: we need postscript_name and glyph widths from the font
              # subset. Perhaps this could be done by querying the subset,
      Severity: Major
      Found in lib/prawn/font/ttf.rb - About 2 hrs to fix

        Method encode_text has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def encode_text(text, options = {})
                text = text.chomp
        
                if options[:kerning]
                  last_subset = nil
        Severity: Minor
        Found in lib/prawn/font/ttf.rb - About 1 hr to fix

          Method compute_width_of has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def compute_width_of(string, options = {}) #:nodoc:
                  scale = (options[:size] || size) / 1000.0
                  if options[:kerning]
                    kern(string).inject(0) do |s, r|
                      if r.is_a?(Numeric)
          Severity: Minor
          Found in lib/prawn/font/ttf.rb - 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

          There are no issues that match your filters.

          Category
          Status