Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/rubocop #40

Merged
merged 3 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 176 additions & 5 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,184 @@
Style/NumericLiterals:
AllCops:
SuggestExtensions: false

Gemspec/RequiredRubyVersion:
Exclude:
- 'open-weather-ruby-client.gemspec'

Naming/FileName:
Exclude:
- 'lib/open-weather-ruby-client.rb'

Gemspec/DevelopmentDependencies:
Enabled: false
Gemspec/RequireMFA:
Enabled: false
Gemspec/DeprecatedAttributeAssignment:
Enabled: true

Style/NumericLiterals:
Enabled: false
Style/ModuleFunction:
Enabled: false

Style/Documentation:
Enabled: false

Metrics:
Enabled: false

inherit_from: .rubocop_todo.yml
Layout/LineContinuationLeadingSpace:
Enabled: true
Layout/LineContinuationSpacing:
Enabled: true
Layout/LineEndStringConcatenationIndentation:
Enabled: true
Layout/SpaceBeforeBrackets:
Enabled: true
Lint/AmbiguousAssignment:
Enabled: true
Lint/AmbiguousOperatorPrecedence:
Enabled: true
Lint/AmbiguousRange:
Enabled: true
Lint/ConstantOverwrittenInRescue:
Enabled: true
Lint/DeprecatedConstants:
Enabled: true
Lint/DuplicateBranch:
Enabled: true
Lint/DuplicateMagicComment:
Enabled: true
Lint/DuplicateRegexpCharacterClassElement:
Enabled: true
Lint/EmptyBlock:
Enabled: true
Lint/EmptyClass:
Enabled: true
Lint/EmptyInPattern:
Enabled: true
Lint/IncompatibleIoSelectWithFiberScheduler:
Enabled: true
Lint/LambdaWithoutLiteralBlock:
Enabled: true
Lint/NoReturnInBeginEndBlocks:
Enabled: true
Lint/NonAtomicFileOperation:
Enabled: true
Lint/NumberedParameterAssignment:
Enabled: true
Lint/OrAssignmentToConstant:
Enabled: true
Lint/RedundantDirGlobSort:
Enabled: true
Lint/RefinementImportMethods:
Enabled: true
Lint/RequireRangeParentheses:
Enabled: true
Lint/RequireRelativeSelfPath:
Enabled: true
Lint/SymbolConversion:
Enabled: true
Lint/ToEnumArguments:
Enabled: true
Lint/TripleQuotes:
Enabled: true
Lint/UnexpectedBlockArity:
Enabled: true
Lint/UnmodifiedReduceAccumulator:
Enabled: true
Lint/UselessRescue:
Enabled: true
Lint/UselessRuby2Keywords:
Enabled: true
Naming/BlockForwarding:
Enabled: true
Security/CompoundHash:
Enabled: true
Security/IoMethods:
Enabled: true
Style/ArgumentsForwarding:
Enabled: true
Style/ArrayIntersect:
Enabled: true
Style/CollectionCompact:
Enabled: true
Style/ComparableClamp:
Enabled: true
Style/ConcatArrayLiterals:
Enabled: true
Style/DirEmpty:
Enabled: true
Style/DocumentDynamicEvalDefinition:
Enabled: true
Style/EmptyHeredoc:
Enabled: true
Style/EndlessMethod:
Enabled: true
Style/EnvHome:
Enabled: true
Style/FetchEnvVar:
Enabled: true
Style/FileEmpty:
Enabled: true
Style/FileRead:
Enabled: true
Style/FileWrite:
Enabled: true
Style/HashConversion:
Enabled: true
Style/HashExcept:
Enabled: true
Style/IfWithBooleanLiteralBranches:
Enabled: true
Style/InPatternThen:
Enabled: true
Style/MagicCommentFormat:
Enabled: true
Style/MapCompactWithConditionalBlock:
Enabled: true
Style/MapToHash:
Enabled: true
Style/MapToSet:
Enabled: true
Style/MinMaxComparison:
Enabled: true
Style/MultilineInPatternThen:
Enabled: true
Style/NegatedIfElseCondition:
Enabled: true
Style/NestedFileDirname:
Enabled: true
Style/NilLambda:
Enabled: true
Style/NumberedParameters:
Enabled: true
Style/NumberedParametersLimit:
Enabled: true
Style/ObjectThen:
Enabled: true
Style/OpenStructUse:
Enabled: true
Style/OperatorMethodCall:
Enabled: true
Style/QuotedSymbols:
Enabled: true
Style/RedundantArgument:
Enabled: true
Style/RedundantConstantBase:
Enabled: true
Style/RedundantDoubleSplatHashBraces:
Enabled: true
Style/RedundantEach:
Enabled: true
Style/RedundantHeredocDelimiterQuotes:
Enabled: true
Style/RedundantInitialize:
Enabled: true
Style/RedundantSelfAssignmentBranch:
Enabled: true
Style/RedundantStringEscape:
Enabled: true
Style/SelectByRegexp:
Enabled: true
Style/StringChars:
Enabled: true
Style/SwapValues:
Enabled: true
44 changes: 0 additions & 44 deletions .rubocop_todo.yml

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 0.5.1 (Next)

* [#40](https://github.com/dblock/open-weather-ruby-client/pull/40): Fixing rubocop violations and improved .rubocop.yml - [@troya2](https://github.com/troya2).
* Your contribution here.

### 0.5.0 (2024/07/03)
Expand Down
2 changes: 1 addition & 1 deletion lib/open_weather/endpoints/stations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_measurements(options)
private

def validate_id(id)
raise ArgumentError, 'Invalid ID' unless id&.is_a?(String)
raise ArgumentError, 'Invalid ID' unless id.is_a?(String)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/open_weather/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module OpenWeather
class Logger < ::Logger
def self.logger
@logger ||= begin
logger = new STDOUT
logger = new $stdout
logger.level = Logger::WARN
logger
end
Expand Down
2 changes: 1 addition & 1 deletion lib/open_weather/models/forecast/forecast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Forecast < Model
property 'rain'
property 'snow'
property 'visibility' # Average visibility, metres. The maximum value of the visibility is 10km
property 'pop' # Probability of precipitation. The values of the parameter vary between 0 and 1, where 0 is equal to 0%, 1 is equal to 100%
property 'pop' # Probability of precipitation. Varies from 0 and 1, where 0 is equal to 0%, 1 is equal to 100%
property 'sys'

def initialize(args = nil, options = {})
Expand Down
4 changes: 2 additions & 2 deletions lib/open_weather/models/mixins/temp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def to_kelvin(value)
when :metric
(value.to_f + 273.15).round(2)
when :imperial
((value.to_f - 32) * 5 / 9 + 273.15).round(2)
(((value.to_f - 32) * 5 / 9) + 273.15).round(2)
else
value
end
Expand All @@ -55,7 +55,7 @@ def to_farenheit(value)
when :imperial
value
else
((value.to_f - 273.15) * 9 / 5 + 32).round(2)
(((value.to_f - 273.15) * 9 / 5) + 32).round(2)
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/open_weather/models/one_call/current_weather.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class CurrentWeather < Model
temperature_property 'feels_like' # temperature, accounts for the human perception of weather
property 'pressure' # atmospheric pressure on the sea level, hPa
property 'humidity' # humidity, %
temperature_property 'dew_point' # atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form
# atmospheric temperature (varying according to pressure and humidity)
# below which water droplets begin to condense and dew can form
temperature_property 'dew_point'
property 'clouds' # cloudiness, %
property 'uvi' # UV index
property 'visibility' # average visibility, meters
Expand Down
4 changes: 3 additions & 1 deletion lib/open_weather/models/one_call/daily_weather.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class DailyWeather < Model
property 'feels_like'
property 'pressure' # atmospheric pressure on the sea level, hPa
property 'humidity' # humidity, %
temperature_property 'dew_point' # atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form
# atmospheric temperature (varying according to pressure and humidity)
# below which water droplets begin to condense and dew can form
temperature_property 'dew_point'
speed_property 'wind_speed' # wind speed
speed_property 'wind_gust' # wind gust
property 'wind_deg' # wind direction, degrees (meteorological)
Expand Down
4 changes: 3 additions & 1 deletion lib/open_weather/models/one_call/hourly_weather.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class HourlyWeather < Model
temperature_property 'feels_like'
property 'pressure' # atmospheric pressure on the sea level, hPa
property 'humidity' # humidity, %
temperature_property 'dew_point' # atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form
# atmospheric temperature (varying according to pressure and humidity)
# below which water droplets begin to condense and dew can form
temperature_property 'dew_point'
property 'clouds' # cloudiness, %
property 'visibility' # average visibility, meters
speed_property 'wind_speed' # wind speed.
Expand Down
2 changes: 1 addition & 1 deletion lib/open_weather/models/stations/measurement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Models
module Stations
class Measurement < Model
property 'station_id' # The internal ID of the station
property 'type' # Type of the aggregated data - minute, hour or day. Specifies the letters m, h or d respectively
property 'type' # Type of the aggregated data - minute, hour or day - the letters m, h or d respectively
property 'date' # Time of measurement
property 'temp'
property 'humidity'
Expand Down
4 changes: 2 additions & 2 deletions spec/open_weather/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
end
end
context 'logger option' do
let(:logger) { Logger.new(STDOUT) }
let(:logger) { Logger.new($stdout) }
before do
OpenWeather::Client.configure do |config|
config.logger = logger
Expand All @@ -110,7 +110,7 @@
expect(client.logger).to eq logger
end
it 'creates a connection with a logger' do
expect(client.send(:connection).builder.handlers).to include ::Faraday::Response::Logger
expect(client.send(:connection).builder.handlers).to include Faraday::Response::Logger
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion spec/open_weather/current/cities_box_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
expect(data.cnt).to eq 15
end
it 'returns cities in a box weather with coordinates' do
data = client.current_cities_geo_box(lon_left: 12, lat_bottom: 32, lon_right: 15, lat_top: 37, zoom: 10, cluster: true)
data = client.current_cities_geo_box(
lon_left: 12, lat_bottom: 32, lon_right: 15, lat_top: 37, zoom: 10, cluster: true
)
expect(data).to be_a OpenWeather::Models::List
expect(data.cnt).to eq 15
end
Expand Down
Loading
Loading