fga-eps-mds/2019.2-Vsign

View on GitHub
backend/app/jobs/face_match_job.rb

Summary

Maintainability
A
25 mins
Test Coverage

Assignment Branch Condition size for perform is too high. [26.31/15]
Open

  def perform(contract_id) 
    
    @client = Aws::Rekognition::Client.new({
      region: Rails.application.credentials.dig(:aws, :region),
      credentials: Aws::Credentials.new(
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [21/10]
Open

  def face_matching(video_image, document_image)
   
    attrs = {
      source_image: {
        s3_object: {
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for face_matching is too high. [19.42/15]
Open

  def face_matching(video_image, document_image)
   
    attrs = {
      source_image: {
        s3_object: {
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [11/10]
Open

  def perform(contract_id) 
    
    @client = Aws::Rekognition::Client.new({
      region: Rails.application.credentials.dig(:aws, :region),
      credentials: Aws::Credentials.new(
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    @client = Aws::Rekognition::Client.new({
      region: Rails.application.credentials.dig(:aws, :region),
      credentials: Aws::Credentials.new(
        Rails.application.credentials.dig(:aws, :access_key_id),
        Rails.application.credentials.dig(:aws, :secret_access_key))
Severity: Minor
Found in backend/app/jobs/face_match_job.rb and 1 other location - About 25 mins to fix
backend/app/jobs/id_confirm_job.rb on lines 5..10

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 29.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Extra blank line detected.
Open


  def perform_next_job(similarity)
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Indent the right brace the same as the first position after the preceding left parenthesis.
Open

    })
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cops checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the AlignHash cop.

By default, Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.

Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.

This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_braces'. Here are examples:

Example: EnforcedStyle: specialinsideparentheses (default)

# The `special_inside_parentheses` style enforces that the first key
# in a hash literal where the opening brace and the first key are on
# separate lines is indented one step (two spaces) more than the
# position inside the opening parentheses.

# bad
hash = {
  key: :value
}
and_in_a_method_call({
  no: :difference
                     })

# good
special_inside_parentheses
hash = {
  key: :value
}
but_in_a_method_call({
                       its_like: :this
                     })

Example: EnforcedStyle: consistent

# The `consistent` style enforces that the first key in a hash
# literal where the opening brace and the first key are on
# seprate lines is indented the same as a hash literal which is not
# defined inside a method call.

# bad
hash = {
  key: :value
}
but_in_a_method_call({
                       its_like: :this
                      })

# good
hash = {
  key: :value
}
and_in_a_method_call({
  no: :difference
})

Example: EnforcedStyle: align_braces

# The `align_brackets` style enforces that the opening and closing
# braces are indented to the same position.

# bad
and_now_for_something = {
                          completely: :different
}

# good
and_now_for_something = {
                          completely: :different
                        }

Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
Open

        Rails.application.credentials.dig(:aws, :secret_access_key))
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.

When using the symmetrical (default) style:

If a method call's opening brace is on the same line as the first argument of the call, then the closing brace should be on the same line as the last argument of the call.

If an method call's opening brace is on the line above the first argument of the call, then the closing brace should be on the line below the last argument of the call.

When using the new_line style:

The closing brace of a multi-line method call must be on the line after the last argument of the call.

When using the same_line style:

The closing brace of a multi-line method call must be on the same line as the last argument of the call.

Example:

# symmetrical: bad
  # new_line: good
  # same_line: bad
  foo(a,
    b
  )

  # symmetrical: bad
  # new_line: bad
  # same_line: good
  foo(
    a,
    b)

  # symmetrical: good
  # new_line: bad
  # same_line: good
  foo(a,
    b)

  # symmetrical: good
  # new_line: good
  # same_line: bad
  foo(
    a,
    b
  )

Trailing whitespace detected.
Open

  private 
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Final newline missing.
Open

end
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Redundant curly braces around a hash parameter.
Open

    @client = Aws::Rekognition::Client.new({
      region: Rails.application.credentials.dig(:aws, :region),
      credentials: Aws::Credentials.new(
        Rails.application.credentials.dig(:aws, :access_key_id),
        Rails.application.credentials.dig(:aws, :secret_access_key))
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks for braces around the last parameter in a method call if the last parameter is a hash. It supports braces, no_braces and context_dependent styles.

Example: EnforcedStyle: braces

# The `braces` style enforces braces around all method
# parameters that are hashes.

# bad
some_method(x, y, a: 1, b: 2)

# good
some_method(x, y, {a: 1, b: 2})

Example: EnforcedStyle: no_braces (default)

# The `no_braces` style checks that the last parameter doesn't
# have braces around it.

# bad
some_method(x, y, {a: 1, b: 2})

# good
some_method(x, y, a: 1, b: 2)

Example: EnforcedStyle: context_dependent

# The `context_dependent` style checks that the last parameter
# doesn't have braces around it, but requires braces if the
# second to last parameter is also a hash literal.

# bad
some_method(x, y, {a: 1, b: 2})
some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)

# good
some_method(x, y, a: 1, b: 2)
some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})

Line is too long. [81/80]
Open

    @contract.image.each |image| face_matching(image.filename, document.filename)
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Use empty lines between method definitions.
Open

  def perform_next_job(similarity)
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Missing space after #.
Open

    #sola de similarity das tres vezes que a funcao eh chamda
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks whether comments have a leading space after the # denoting the start of the comment. The leading space is not required for some RDoc special syntax, like #++, #--, #:nodoc, =begin- and =end comments, "shebang" directives, or rackup options.

Example:

# bad
#Some comment

# good
# Some comment

Trailing whitespace detected.
Open

    
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Missing top-level class documentation comment.
Open

class FaceMatchJob < ApplicationJob
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Surrounding space missing for operator |.
Open

    @contract.image.each |image| face_matching(image.filename, document.filename)
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Trailing whitespace detected.
Open

    
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Trailing whitespace detected.
Open

  
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Extra empty line detected at class body end.
Open


end
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cops checks if empty lines around the bodies of classes match the configuration.

Example: EnforcedStyle: empty_lines

# good

class Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

class Foo
  class Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
class Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

class Foo
  def bar
    # ...
  end
end

Trailing whitespace detected.
Open

  def perform(contract_id) 
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Trailing whitespace detected.
Open

   
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Line is too long. [81/80]
Open

          bucket: Rails.application.credentials[Rails.env.to_sym][:aws][:bucket],
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
Open

      region: Rails.application.credentials.dig(:aws, :region),
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cops checks the indentation of the first key in a hash literal where the opening brace and the first key are on separate lines. The other keys' indentations are handled by the AlignHash cop.

By default, Hash literals that are arguments in a method call with parentheses, and where the opening curly brace of the hash is on the same line as the opening parenthesis of the method call, shall have their first key indented one step (two spaces) more than the position inside the opening parenthesis.

Other hash literals shall have their first key indented one step more than the start of the line where the opening curly brace is.

This default style is called 'specialinsideparentheses'. Alternative styles are 'consistent' and 'align_braces'. Here are examples:

Example: EnforcedStyle: specialinsideparentheses (default)

# The `special_inside_parentheses` style enforces that the first key
# in a hash literal where the opening brace and the first key are on
# separate lines is indented one step (two spaces) more than the
# position inside the opening parentheses.

# bad
hash = {
  key: :value
}
and_in_a_method_call({
  no: :difference
                     })

# good
special_inside_parentheses
hash = {
  key: :value
}
but_in_a_method_call({
                       its_like: :this
                     })

Example: EnforcedStyle: consistent

# The `consistent` style enforces that the first key in a hash
# literal where the opening brace and the first key are on
# seprate lines is indented the same as a hash literal which is not
# defined inside a method call.

# bad
hash = {
  key: :value
}
but_in_a_method_call({
                       its_like: :this
                      })

# good
hash = {
  key: :value
}
and_in_a_method_call({
  no: :difference
})

Example: EnforcedStyle: align_braces

# The `align_brackets` style enforces that the opening and closing
# braces are indented to the same position.

# bad
and_now_for_something = {
                          completely: :different
}

# good
and_now_for_something = {
                          completely: :different
                        }

Redundant return detected.
Open

    return similarity
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks for redundant return expressions.

Example:

def test
  return something
end

def test
  one
  two
  three
  return something
end

It should be extended to handle methods whose body is if/else or a case expression with a default branch.

Extra empty line detected at method body end.
Open


  end
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cops checks if empty lines exist around the bodies of methods.

Example:

# good

def foo
  # ...
end

# bad

def bar

  # ...

end

Trailing whitespace detected.
Open

  
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Line is too long. [81/80]
Open

          bucket: Rails.application.credentials[Rails.env.to_sym][:aws][:bucket],
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Surrounding space missing for operator |.
Open

    @contract.image.each |image| face_matching(image.filename, document.filename)
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Trailing whitespace detected.
Open

    
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Extra empty line detected at method body end.
Open


  end
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cops checks if empty lines exist around the bodies of methods.

Example:

# good

def foo
  # ...
end

# bad

def bar

  # ...

end

Trailing whitespace detected.
Open

    
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Trailing whitespace detected.
Open

  
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

      @contract.status = "error, face matching fail"
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Avoid comma after the last item of a hash.
Open

        },
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks for trailing comma in array and hash literals.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = [1, 2,]

# good
a = [
  1, 2,
  3,
]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: comma

# bad
a = [1, 2,]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = [1, 2,]

# good
a = [
  1,
  2
]

Avoid comma after the last item of a hash.
Open

        },
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop checks for trailing comma in array and hash literals.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = [1, 2,]

# good
a = [
  1, 2,
  3,
]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: comma

# bad
a = [1, 2,]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = [1, 2,]

# good
a = [
  1,
  2
]

Use self-assignment shorthand +=.
Open

      similarity = similarity + face_match.similarity
Severity: Minor
Found in backend/app/jobs/face_match_job.rb by rubocop

This cop enforces the use the shorthand for self-assignment.

Example:

# bad
x = x + 1

# good
x += 1

There are no issues that match your filters.

Category
Status