mozilla/ssh_scan

View on GitHub

Showing 60 of 80 total issues

Function parseRubyEngineAndVersion has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function parseRubyEngineAndVersion(rubyVersion) {
  if (rubyVersion === 'default') {
    if (fs.existsSync('.ruby-version')) {
      rubyVersion = '.ruby-version'
    } else if (fs.existsSync('.tool-versions')) {
Severity: Minor
Found in .github/actions/setup-ruby-1.71.0/index.js - 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

Function setupRuby has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export async function setupRuby(options = {}) {
  const inputs = { ...options }
  for (const key in inputDefaults) {
    if (!Object.prototype.hasOwnProperty.call(inputs, key)) {
      inputs[key] = core.getInput(key) || inputDefaults[key]
Severity: Minor
Found in .github/actions/setup-ruby-1.71.0/index.js - 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 enumerateIPRange has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def enumerateIPRange(ip,port=nil)
      if ip.fqdn?
        if port.nil?
          socket = ip
        else
Severity: Minor
Found in lib/ssh_scan/target_parser.rb - About 1 hr to fix

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

    function parseRubyEngineAndVersion(rubyVersion) {
      if (rubyVersion === 'default') {
        if (fs.existsSync('.ruby-version')) {
          rubyVersion = '.ruby-version'
        } else if (fs.existsSync('.tool-versions')) {
    Severity: Minor
    Found in .github/actions/setup-ruby-1.71.0/index.js - About 1 hr to fix

      Method recommendations has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def recommendations
            recommendations = []
      
            # Add these items to be compliant
            if missing_policy_kex.any?
      Severity: Minor
      Found in lib/ssh_scan/policy_manager.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 os_guess has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def os_guess()
            case @string
            when /Ubuntu/i
              return SSHScan::OS::Ubuntu.new(@string)
            when /6.6p1-5build1/i # non-standard Ubuntu release
      Severity: Minor
      Found in lib/ssh_scan/banner.rb - About 1 hr to fix

        Function setupPath has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export function setupPath(newPathEntries) {
          const envPath = windows ? 'Path' : 'PATH'
          const originalPath = process.env[envPath].split(path.delimiter)
          let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
        
        
        Severity: Minor
        Found in .github/actions/setup-ruby-1.71.0/common.js - 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

        Function bundleInstall has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVersion, bundlerVersion, cacheVersion) {
        Severity: Major
        Found in .github/actions/setup-ruby-1.71.0/bundler.js - About 50 mins to fix

          Function install has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export async function install(platform, engine, version) {
            const url = rubyInstallerVersions[version]
          
            if (!url.endsWith('.7z')) {
              throw new Error(`URL should end in .7z: ${url}`)
          Severity: Minor
          Found in .github/actions/setup-ruby-1.71.0/windows.js - 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 ubuntu_version_guess has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def ubuntu_version_guess
                  possible_versions = []
                  OS::Ubuntu::FINGERPRINTS.keys.each do |ubuntu_version|
                    OS::Ubuntu::FINGERPRINTS[ubuntu_version].uniq.each do |banner|
                      openssh_ps, ubuntu_sig = banner.split("-")
          Severity: Minor
          Found in lib/ssh_scan/os/ubuntu.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

          Function validateRubyEngineAndVersion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion) {
            if (!engineVersions) {
              throw new Error(`Unknown engine ${engine} on ${platform}`)
            }
          
          
          Severity: Minor
          Found in .github/actions/setup-ruby-1.71.0/index.js - 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

          Function installBundler has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          export async function installBundler(bundlerVersionInput, lockFile, platform, rubyPrefix, engine, rubyVersion) {
          Severity: Minor
          Found in .github/actions/setup-ruby-1.71.0/bundler.js - About 45 mins to fix

            Function computeBaseKey has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            async function computeBaseKey(platform, engine, version, lockFile, cacheVersion) {
            Severity: Minor
            Found in .github/actions/setup-ruby-1.71.0/bundler.js - About 35 mins to fix

              Function downloadAndExtract has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
              Severity: Minor
              Found in .github/actions/setup-ruby-1.71.0/windows.js - About 35 mins to fix

                Function addVCVARSEnv has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                export function addVCVARSEnv() {
                  const vcVars = '"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat"'
                  core.exportVariable('VCVARS', vcVars)
                
                  let newEnv = new Map()
                Severity: Minor
                Found in .github/actions/setup-ruby-1.71.0/windows.js - 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

                Function readBundledWithFromGemfileLock has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function readBundledWithFromGemfileLock(lockFile) {
                  if (lockFile !== null && fs.existsSync(lockFile)) {
                    const contents = fs.readFileSync(lockFile, 'utf8')
                    const lines = contents.split(/\r?\n/)
                    const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim()))
                Severity: Minor
                Found in .github/actions/setup-ruby-1.71.0/bundler.js - 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

                Function install has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                export async function install(platform, engine, version) {
                  let rubyPrefix, inToolCache
                  if (common.shouldUseToolCache(engine, version)) {
                    inToolCache = tc.find('Ruby', version)
                    if (inToolCache) {
                Severity: Minor
                Found in .github/actions/setup-ruby-1.71.0/ruby-builder.js - 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

                Method hexify has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def hexify(opts={})
                    delim = opts[:delim]
                    pre = (opts[:prefix] || "")
                    suf = (opts[:suffix] || "")
                
                
                Severity: Minor
                Found in lib/string_ext.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

                Avoid too many return statements within this method.
                Open

                        return SSHScan::OS::FreeBSD.new
                Severity: Major
                Found in lib/ssh_scan/banner.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                            return "unknown"
                  Severity: Major
                  Found in lib/ssh_scan/public_key.rb - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language