vinc/forecaster

View on GitHub

Showing 6 of 6 total issues

Method get_location has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def get_location(opts, env)
      if (opts[:location] || "").length > 0
        @store.transaction do
          if opts[:debug]
            putf_debug("Geolocalizing", opts[:location], "'%s'")
Severity: Minor
Found in lib/forecaster/cli.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 get_forecast has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get_forecast(time, opts)
      forecast = Forecast.at(time)

      if opts[:debug]
        putf_debug("Requested time", time.localtime,              "%s")
Severity: Minor
Found in lib/forecaster/cli.rb - About 1 hr to fix

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

        def parse(args)
          opts = Optimist.options(args) do
            version         "Forecaster v#{Forecaster::VERSION}"
            banner          "Usage: forecast for <time> in <location>"
            banner          ""
    Severity: Minor
    Found in lib/forecaster/cli.rb - About 1 hr to fix

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

          def print_forecast(forecast, lat, lon)
            putf("Date", forecast.time.localtime.strftime("%Y-%m-%d"), "%s")
            putf("Time", forecast.time.localtime.strftime("%T"),       "%s")
            putf("Zone", forecast.time.localtime.strftime("%z"),       "%s")
      
      
      Severity: Minor
      Found in lib/forecaster/cli.rb - About 1 hr to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(year, month, day, run_hour, fct_hour)
        Severity: Minor
        Found in lib/forecaster/forecast.rb - About 35 mins to fix

          Method fetch has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def self.fetch(year, month, day, hour_of_run, hour_of_forecast)
          Severity: Minor
          Found in lib/forecaster.rb - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language