shinsaka/fluent-plugin-elb-log

View on GitHub

Showing 8 of 8 total issues

File in_elb_log.rb has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'time'
require 'zlib'
require 'fileutils'
require 'aws-sdk-s3'
require 'aws-sdk-ec2'
Severity: Minor
Found in lib/fluent/plugin/in_elb_log.rb - About 3 hrs to fix

    Method emit_lines_from_buffer_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def emit_lines_from_buffer_file(record_common)
        begin
          # emit per line
          File.open(@buf_file, File::RDONLY) do |file|
            file.each_line do |line|
    Severity: Minor
    Found in lib/fluent/plugin/in_elb_log.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

    Method get_object_keys has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get_object_keys(timestamp)
        object_keys = []
    
        resp = s3_client.list_objects_v2(
          bucket: @s3_bucketname,
    Severity: Minor
    Found in lib/fluent/plugin/in_elb_log.rb - About 1 hr to fix

      Method format_record has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def format_record(item)
          { "time" => item[:time].gsub(/Z/, '+0000'),
            "elb" => item[:elb],
            "client" => item[:client],
            "client_port" => item[:client_port],
      Severity: Minor
      Found in lib/fluent/plugin/in_elb_log.rb - About 1 hr to fix

        Method configure has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def configure(conf)
            super
        
            if !has_iam_role?
              raise Fluent::ConfigError.new("access_key_id is required") if @access_key_id.nil?
        Severity: Minor
        Found in lib/fluent/plugin/in_elb_log.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

        Method get_object_keys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_object_keys(timestamp)
            object_keys = []
        
            resp = s3_client.list_objects_v2(
              bucket: @s3_bucketname,
        Severity: Minor
        Found in lib/fluent/plugin/in_elb_log.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

        Method input has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def input
            begin
              log.debug "start"
              timestamp = get_timestamp_file()
        
        
        Severity: Minor
        Found in lib/fluent/plugin/in_elb_log.rb - About 1 hr to fix

          Method get_timestamp_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_timestamp_file
              begin
                # get timestamp last proc
                start_time = @start_time ? Time.parse(@start_time).utc : Time.at(0)
                timestamp = start_time.to_i
          Severity: Minor
          Found in lib/fluent/plugin/in_elb_log.rb - 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

          Severity
          Category
          Status
          Source
          Language