webdestroya/sourcemod-translator

View on GitHub

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

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

            def create
              @phrase = Phrase.new(phrase_params)
          
              respond_to do |format|
                if @phrase.save
          Severity: Major
          Found in app/controllers/phrases_controller.rb and 1 other location - About 1 hr to fix
          app/controllers/format_infos_controller.rb on lines 41..50

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

          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 create
              @format_info = FormatInfo.new(format_info_params)
          
              respond_to do |format|
                if @format_info.save
          Severity: Major
          Found in app/controllers/format_infos_controller.rb and 1 other location - About 1 hr to fix
          app/controllers/phrases_controller.rb on lines 43..52

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

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

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

              def update
                respond_to do |format|
                  if @format_info.update_attributes(format_info_params)
                    format.html { redirect_to @format_info, notice: 'Format info was successfully updated.' }
                    format.json { head :no_content }
            Severity: Minor
            Found in app/controllers/format_infos_controller.rb and 1 other location - About 45 mins to fix
            app/controllers/phrases_controller.rb on lines 59..66

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

            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 update
                respond_to do |format|
                  if @phrase.update_attributes(phrase_params)
                    format.html { redirect_to @phrase, notice: 'Phrase was successfully updated.' }
                    format.json { head :no_content }
            Severity: Minor
            Found in app/controllers/phrases_controller.rb and 1 other location - About 45 mins to fix
            app/controllers/format_infos_controller.rb on lines 57..64

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

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

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

                respond_to do |format|
                  if @user_lang.save
                    format.html { redirect_to languages_path, notice: "We have added #{@language.name} to your list" }
                  else
                    format.html { redirect_to languages_path, notice: "PROBLEM" }
            Severity: Minor
            Found in app/controllers/languages_controller.rb and 1 other location - About 15 mins to fix
            app/controllers/languages_controller.rb on lines 29..33

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

            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

                respond_to do |format|
                  if @userlang.destroy
                    format.html { redirect_to languages_path, notice: "We have removed #{@language.name} from your list" }
                  else
                    format.html { redirect_to languages_path, notice: "PROBLEM" }
            Severity: Minor
            Found in app/controllers/languages_controller.rb and 1 other location - About 15 mins to fix
            app/controllers/languages_controller.rb on lines 14..18

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

            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