webdestroya/sourcemod-translator

View on GitHub
app/controllers/sourcemod_plugins_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

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

        There are no issues that match your filters.

        Category
        Status