GospelToolbox/Labs

View on GitHub

Showing 26 of 26 total issues

Method refresh has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  def refresh
    schedule = {
      service_types: {},
      service_type_teams: {},
      records: {},
Severity: Minor
Found in app/controllers/api/teamschedule/v1/schedule_controller.rb - About 3 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

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

            if(padGains[id]) {
              padGains[id].gain.setValueAtTime(padGains[id].gain.value, audioContext.currentTime);
              padGains[id].gain.exponentialRampToValueAtTime(1 - padGains[id].gain.value, audioContext.currentTime + 1  );
            }
Severity: Major
Found in engines/set_live/app/javascript/packs/sets_show.js and 1 other location - About 2 hrs to fix
engines/set_live/app/javascript/packs/sets_show.js on lines 107..110

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

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

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

    $('#mute_pad_'+id).click(function() {
        padGains[id].gain.setValueAtTime(padGains[id].gain.value, audioContext.currentTime);
        padGains[id].gain.exponentialRampToValueAtTime(1 - padGains[id].gain.value, audioContext.currentTime + 1  );
    });
Severity: Major
Found in engines/set_live/app/javascript/packs/sets_show.js and 1 other location - About 2 hrs to fix
engines/set_live/app/javascript/packs/sets_show.js on lines 229..232

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

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

  def refresh
    schedule = {
      service_types: {},
      service_type_teams: {},
      records: {},
Severity: Major
Found in app/controllers/api/teamschedule/v1/schedule_controller.rb - About 2 hrs to fix

    Function render has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        const {
          selected,
          organizations
        } = this.state;
    Severity: Minor
    Found in app/javascript/components/OrganizationDropDown.jsx - About 1 hr to fix

      Function connectLaunchpad has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function connectLaunchpad() {
          launchpad = new Launchpad(navigator);
      
          launchpad.onConnect(function() {
            resetLaunchpadColors();
      Severity: Minor
      Found in engines/set_live/app/javascript/packs/sets_show.js - About 1 hr to fix

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

          keyUp(key) {
            let coords = this.coordsFromKey(key)
        
            this.keyUpHandlers.forEach(function(handler) {
              handler(coords[0], coords[1]);
        Severity: Major
        Found in engines/set_live/app/javascript/launchpad.js and 1 other location - About 1 hr to fix
        engines/set_live/app/javascript/launchpad.js on lines 94..100

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

        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

          keyDown(key) {
            let coords = this.coordsFromKey(key)
        
            this.keyDownHandlers.forEach(function(handler) {
              handler(coords[0], coords[1]);
        Severity: Major
        Found in engines/set_live/app/javascript/launchpad.js and 1 other location - About 1 hr to fix
        engines/set_live/app/javascript/launchpad.js on lines 86..92

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

        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

        Function NavUserProfile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const NavUserProfile = (props) => {
          const {
            email,
            logout_url
          } = props;
        Severity: Minor
        Found in app/javascript/components/NavUserProfile.jsx - About 1 hr to fix

          Function renderRefreshButton has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            renderRefreshButton() {
              const {
                has_token,
                organization,
                is_refreshing
          Severity: Minor
          Found in app/javascript/apps/teamschedule/App.jsx - About 1 hr to fix

            Function generateTeamPositionRowCells has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function generateTeamPositionRowCells(context) {
              const {
                schedule,
                serviceTypeId,
                teamId,
            Severity: Minor
            Found in app/javascript/apps/teamschedule/TeamScheduleTable.jsx - About 1 hr to fix

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

                  def sync
                    @plan = PCO::Plan.find(params[:set_id])
              
                    ids_to_delete = @plan.pco_plan_items.map(&:pco_id).to_a
                    api.plan_items(@plan.pco_service_type.pco_id, @plan.pco_id).each do |item|
              Severity: Minor
              Found in engines/set_live/app/controllers/set_live/sets_controller.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 enumerate_paged_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def enumerate_paged_response(per_page: 25)
                    offset = 0
                    fetch_more = true
              
                    all_data = []
              Severity: Minor
              Found in engines/pco/lib/pco/source_api.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

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

                def auth
                  session[:redirect_to] = params[:redirect_to] unless params[:redirect_to].nil?
                  session[:organization_id] = params[:organization_id] unless params[:organization_id].nil?
              
                  url = client.auth_code.authorize_url(
              Severity: Minor
              Found in app/controllers/planning_center_controller.rb and 1 other location - About 35 mins to fix
              app/controllers/spotify_controller.rb on lines 7..15

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

              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 auth
                  session[:redirect_to] = params[:redirect_to] unless params[:redirect_to].nil?
                  session[:organization_id] = params[:organization_id] unless params[:organization_id].nil?
              
                  url = client.auth_code.authorize_url(
              Severity: Minor
              Found in app/controllers/spotify_controller.rb and 1 other location - About 35 mins to fix
              app/controllers/planning_center_controller.rb on lines 7..15

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

              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

                class Engine < ::Rails::Engine
                  isolate_namespace PCO
              
                  initializer :append_migrations do |app|
                    unless app.root.to_s.match root.to_s
              Severity: Minor
              Found in engines/pco/lib/pco/engine.rb and 1 other location - About 25 mins to fix
              engines/set_planner/lib/set_planner/engine.rb on lines 2..8

              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

                class Engine < ::Rails::Engine
                  isolate_namespace SetPlanner
              
                  initializer :append_migrations do |app|
                    unless app.root.to_s.match root.to_s
              Severity: Minor
              Found in engines/set_planner/lib/set_planner/engine.rb and 1 other location - About 25 mins to fix
              engines/pco/lib/pco/engine.rb on lines 2..8

              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 store_token(token)
                  pco_token = PlanningCenterToken.find_by organization_id: session[:organization_id]
                  pco_token ||= PlanningCenterToken.new organization_id: session[:organization_id]
              
                  pco_token.token = token.to_json
              Severity: Minor
              Found in app/controllers/planning_center_controller.rb and 1 other location - About 25 mins to fix
              app/controllers/spotify_controller.rb on lines 36..43

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

              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 store_token(token)
                  spotify_token = SpotifyToken.find_by organization_id: session[:organization_id]
                  spotify_token ||= SpotifyToken.new organization_id: session[:organization_id]
              
                  spotify_token.token = token.to_json
              Severity: Minor
              Found in app/controllers/spotify_controller.rb and 1 other location - About 25 mins to fix
              app/controllers/planning_center_controller.rb on lines 37..44

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

              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 save_song has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def save_song(song)
                    attrs = song['attributes']
                    
                    song_model = PCO::Song.where(organization_id: @org_id, pco_id: song['id'])
                              .first_or_create
              Severity: Minor
              Found in engines/pco/lib/pco/synchronizer.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