gitlabhq/gitlabhq

View on GitHub
lib/gitlab/gitaly_client/wiki_service.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method wiki_page_from_iterator has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def wiki_page_from_iterator(iterator)
        wiki_page = version = nil

        while message = iterator.next
          break if block_given? && yield(message)
Severity: Minor
Found in lib/gitlab/gitaly_client/wiki_service.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

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

      def find_file(name, revision)
        request = Gitaly::WikiFindFileRequest.new(
          repository: @gitaly_repo,
          name: encode_binary(name),
          revision: encode_binary(revision)
Severity: Minor
Found in lib/gitlab/gitaly_client/wiki_service.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 update_page has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def update_page(page_path, title, format, content, commit_details)
Severity: Minor
Found in lib/gitlab/gitaly_client/wiki_service.rb - About 35 mins to fix

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

          def load_all_pages(limit: 0, sort: nil, direction_desc: false)
            sort_value = Gitaly::WikiGetAllPagesRequest::SortBy.resolve(sort.to_s.upcase.to_sym)
    
            params = { repository: @gitaly_repo, limit: limit, direction_desc: direction_desc }
            params[:sort] = sort_value if sort_value
    Severity: Minor
    Found in lib/gitlab/gitaly_client/wiki_service.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

    There are no issues that match your filters.

    Category
    Status