esigler/lita-locker

View on GitHub

Showing 15 of 15 total issues

Class Label has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Label
      include Redis::Objects

      value :state
      value :owner_id
Severity: Minor
Found in lib/locker/label.rb - About 2 hrs to fix

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

          def unobserve(response)
            name = response.match_data['label']
            user = response.user
            return response.reply(failed(t('label.does_not_exist', name: name))) unless Label.exists?(name)
            l = Label.new(name)
    Severity: Major
    Found in lib/lita/handlers/locker.rb and 1 other location - About 1 hr to fix
    lib/lita/handlers/locker.rb on lines 104..111

    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 57.

    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

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

          def observe(response)
            name = response.match_data['label']
            user = response.user
            return response.reply(failed(t('label.does_not_exist', name: name))) unless Label.exists?(name)
            l = Label.new(name)
    Severity: Major
    Found in lib/lita/handlers/locker.rb and 1 other location - About 1 hr to fix
    lib/lita/handlers/locker.rb on lines 114..121

    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 57.

    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

    Method remove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def remove(response)
            results = []
            resource_names = response.match_data['resources'].split(/,\s*/)
            label_name = response.match_data['label']
            return response.reply(failed(t('label.does_not_exist', name: label_name))) unless Label.exists?(label_name)
    Severity: Minor
    Found in lib/lita/handlers/locker_labels.rb - About 55 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

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

          def give(response)
            name = response.match_data['label'].rstrip
    
            return response.reply(failed(t('subject.does_not_exist', name: name))) unless Label.exists?(name)
            l = Label.new(name)
    Severity: Minor
    Found in lib/lita/handlers/locker.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

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

          def status(response)
            name = response.match_data['label']
            unless name.match(/\*/)
              # Literal query
              return response.reply(status_label(name)) if Label.exists?(name)
    Severity: Minor
    Found in lib/lita/handlers/locker_misc.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

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

          def unlock(response)
            name = response.match_data['label'].rstrip
    
            return response.reply(failed(t('subject.does_not_exist', name: name))) unless Label.exists?(name)
            l = Label.new(name)
    Severity: Minor
    Found in lib/lita/handlers/locker.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

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

              case state
              when 'unlocked'
                unlocked(t('resource.desc', name: key, state: state))
              when 'locked'
                locked(t('resource.desc', name: key, state: state))
    Severity: Minor
    Found in lib/lita/handlers/locker_resources.rb and 1 other location - About 25 mins to fix
    lib/lita/handlers/locker_labels.rb on lines 73..81

    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 31.

    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

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

              case state
              when 'unlocked'
                unlocked(t('label.desc', name: key, state: state))
              when 'locked'
                locked(t('label.desc', name: key, state: state))
    Severity: Minor
    Found in lib/lita/handlers/locker_labels.rb and 1 other location - About 25 mins to fix
    lib/lita/handlers/locker_resources.rb on lines 65..73

    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 31.

    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

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

          def label_show(request, response)
            name = request.env['router.params'][:name]
            response.headers['Content-Type'] = 'application/json'
            unless Label.exists?(name)
              response.status = 404
    Severity: Minor
    Found in lib/lita/handlers/locker_http.rb and 1 other location - About 25 mins to fix
    lib/lita/handlers/locker_http.rb on lines 28..36

    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 31.

    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

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

          def resource_show(request, response)
            name = request.env['router.params'][:name]
            response.headers['Content-Type'] = 'application/json'
            unless Resource.exists?(name)
              response.status = 404
    Severity: Minor
    Found in lib/lita/handlers/locker_http.rb and 1 other location - About 25 mins to fix
    lib/lita/handlers/locker_http.rb on lines 17..25

    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 31.

    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

    Method lock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def lock(response)
            name = response.match_data['label'].rstrip
    
            return response.reply(failed(t('label.does_not_exist', name: name))) unless Label.exists?(name)
            l = Label.new(name)
    Severity: Minor
    Found in lib/lita/handlers/locker.rb - 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

    Method lock! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def lock!(owner_id)
            if locked?
              wait_queue << owner_id if wait_queue.last != owner_id
              return false
            end
    Severity: Minor
    Found in lib/locker/label.rb - 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

    Method list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def list(response)
            begin
              list = ::Locker::List.new(Resource, config.per_page, response.extensions[:kwargs][:page])
            rescue ArgumentError
              return response.reply(t('list.invalid_page_type'))
    Severity: Minor
    Found in lib/lita/handlers/locker_resources.rb - 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

    Method list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def list(response)
            begin
              list = ::Locker::List.new(Label, config.per_page, response.extensions[:kwargs][:page])
            rescue ArgumentError
              return response.reply(t('list.invalid_page_type'))
    Severity: Minor
    Found in lib/lita/handlers/locker_labels.rb - 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