webdestroya/sourcemod-translator

View on GitHub

Showing 12 of 18 total issues

Method load_from_file has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

  def load_from_file(input_stream)
    valid_lines = []

    input_stream.readlines.each do |line|
      line.strip!
Severity: Minor
Found in app/models/sourcemod_plugin.rb - About 7 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 load_from_file has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def load_from_file(input_stream)
    valid_lines = []

    input_stream.readlines.each do |line|
      line.strip!
Severity: Major
Found in app/models/sourcemod_plugin.rb - About 2 hrs to fix

    Method upload_submit has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      def upload_submit
        authorize! :upload, @sourcemod_plugin
    
        if params[:sourcemod_plugin].nil? || params[:sourcemod_plugin][:file].nil?
          flash[:error] = "Sorry, there was a problem with your upload."
    Severity: Minor
    Found in app/controllers/sourcemod_plugins_controller.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 index has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
    
        @sourcemod_plugin = SourcemodPlugin.new
    
        @sourcemod_plugin.name = params[:name] || ''
    Severity: Minor
    Found in app/controllers/sourcemod_plugins_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

    Method download has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def download
        authorize! :download, @sourcemod_plugin
    
        filename = params[:filename]
        filename ||= "#{@sourcemod_plugin.filename}.translations.zip"
    Severity: Minor
    Found in app/controllers/sourcemod_plugins_controller.rb - About 1 hr to fix

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

        def download
          authorize! :download, @sourcemod_plugin
      
          filename = params[:filename]
          filename ||= "#{@sourcemod_plugin.filename}.translations.zip"
      Severity: Minor
      Found in app/controllers/sourcemod_plugins_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

      Method index has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def index
      
          @sourcemod_plugin = SourcemodPlugin.new
      
          @sourcemod_plugin.name = params[:name] || ''
      Severity: Minor
      Found in app/controllers/sourcemod_plugins_controller.rb - About 1 hr to fix

        Method generate_format_info has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def generate_format_info(list)
            return if self.format.nil?
        
            formats = self.format.split ','
        
        
        Severity: Minor
        Found in app/models/phrase.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

        Method upload_submit has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def upload_submit
            authorize! :upload, @sourcemod_plugin
        
            if params[:sourcemod_plugin].nil? || params[:sourcemod_plugin][:file].nil?
              flash[:error] = "Sorry, there was a problem with your upload."
        Severity: Minor
        Found in app/controllers/sourcemod_plugins_controller.rb - About 1 hr to fix

          Method random has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def random
              if current_user.nil?
                flash[:error] = "You must be logged in!"
                redirect_to sourcemod_plugins_path and return
              end
          Severity: Minor
          Found in app/controllers/translations_controller.rb - About 1 hr to fix

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

              def random
                if current_user.nil?
                  flash[:error] = "You must be logged in!"
                  redirect_to sourcemod_plugins_path and return
                end
            Severity: Minor
            Found in app/controllers/translations_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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                @translation = current_user.translations.new(translation_params)
                @phrase = @translation.phrase
                finished_lang_ids = @phrase.languages.collect{|o|o.id}
            
            
            Severity: Minor
            Found in app/controllers/translations_controller.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

            Severity
            Category
            Status
            Source
            Language