clairelee/directable

View on GitHub

Showing 11 of 11 total issues

Method create has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def create
        # Create a new profile if a profile matching the name doesn't exist yet
        @note = @user.new_note(note_params)
    
        if @note.save
Severity: Minor
Found in app/controllers/notes_controller.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

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

        it 'should successfully add a new note for fields on first page and redirect to page with musician specific fields' do
            @production = Production.create(:name => "Dummy Production")
            @production.save
            @note = Note.create({:name => "Double Note", :production_id => 1})
            @note.save
Severity: Major
Found in spec/controllers/notes_controller_spec.rb and 1 other location - About 1 hr to fix
spec/controllers/notes_controller_spec.rb on lines 40..55

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

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

        it 'should successfully add a new note for fields on first page and redirect to page with actor specific fields' do
            @production = Production.create(:name => "Dummy Production")
            @production.save
            @note = Note.create(:name => "Double Note", :production_id => 1)
            @note.save
Severity: Major
Found in spec/controllers/notes_controller_spec.rb and 1 other location - About 1 hr to fix
spec/controllers/notes_controller_spec.rb on lines 22..37

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

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 path_to has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def path_to(page_name)
    case page_name

    when /^the home\s?page$/
      '/'
Severity: Minor
Found in features/support/paths.rb - About 1 hr to fix

    Method search has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def search
            flash[:search_result_notice] = ""
            filtered_notes = @user.all_notes
            if note_params[:name] != ""
                filtered_notes = filtered_notes.where("lower(name) like ?", "%#{note_params[:name]}%")
    Severity: Minor
    Found in app/controllers/notes_controller.rb - About 1 hr to fix

      Method create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def create
              # Create a new profile if a profile matching the name doesn't exist yet
              @note = @user.new_note(note_params)
          
              if @note.save
      Severity: Minor
      Found in app/controllers/notes_controller.rb - About 1 hr to fix

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

            def search
                flash[:search_result_notice] = ""
                filtered_notes = @user.all_notes
                if note_params[:name] != ""
                    filtered_notes = filtered_notes.where("lower(name) like ?", "%#{note_params[:name]}%")
        Severity: Minor
        Found in app/controllers/notes_controller.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

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

        Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
          with_scope(parent) do
            field = find_field(field)
            field_value = (field.tag_name == 'textarea') ? field.text : field.value
            if field_value.respond_to? :should_not
        Severity: Minor
        Found in features/step_definitions/web_steps.rb and 1 other location - About 35 mins to fix
        features/step_definitions/web_steps.rb on lines 141..148

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

        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

        Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
          with_scope(parent) do
            field = find_field(field)
            field_value = (field.tag_name == 'textarea') ? field.text : field.value
            if field_value.respond_to? :should
        Severity: Minor
        Found in features/step_definitions/web_steps.rb and 1 other location - About 35 mins to fix
        features/step_definitions/web_steps.rb on lines 153..160

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

        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

        Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
          regexp = Regexp.new(regexp)
        
          if page.respond_to? :should
            page.should have_xpath('//*', :text => regexp)
        Severity: Minor
        Found in features/step_definitions/web_steps.rb and 1 other location - About 20 mins to fix
        features/step_definitions/web_steps.rb on lines 131..137

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

        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

        Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
          regexp = Regexp.new(regexp)
        
          if page.respond_to? :should
            page.should have_no_xpath('//*', :text => regexp)
        Severity: Minor
        Found in features/step_definitions/web_steps.rb and 1 other location - About 20 mins to fix
        features/step_definitions/web_steps.rb on lines 113..119

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

        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

        Severity
        Category
        Status
        Source
        Language