porkchopclub/porkchop

View on GitHub

Showing 5 of 104 total issues

Class Match has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

class Match < ActiveRecord::Base
  WINNER_SQL = %{ "matches"."victor_id" }.freeze
  LOSER_SQL = <<-SQL.freeze
    CASE
    WHEN "matches"."victor_id" = "home_player_id" THEN "away_player_id"
Severity: Minor
Found in app/models/match.rb - About 3 hrs to fix

    Class Personal has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Stats::Personal
      def initialize(player)
        @player = player
      end
    
    
    Severity: Minor
    Found in app/services/stats/personal.rb - About 2 hrs to fix

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

      const InactivePlayersList = (props) => {
        const { retiredPlayers, unretiredPlayers, activatePlayer } = props
      
        const retiredPlayerListItems = retiredPlayers.map((player) => {
          return (
      Severity: Minor
      Found in app/javascript/components/scoreboard/InactivePlayersList.js - About 1 hr to fix

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

          def self.setup!(matchup = nil, table: Table.default)
            matchup ||= Matchmaker.choose
            return unless matchup.valid?
        
            player1, player2 = *matchup.players.sort_by(&:name)
        Severity: Minor
        Found in app/models/match.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 game_point has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def game_point
            return if finished?
            if highest_score >= 10 && score_differential > 0
              leader == home_player ? :home : :away
            end
        Severity: Minor
        Found in app/models/match.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