Skip to content

Commit

Permalink
fix(Credo): Snake Case variable names (#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
kotva006 authored Jun 7, 2024
1 parent da46bff commit 7a86d16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions lib/algolia/request.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ defmodule Algolia.Query.Request do
attributesToHighlight: String.t() | [String.t()]
}
@spec new(String.t(), String.t()) :: t()
def new(indexName, query) when indexName in @supported_index_keys do
algoliaIndex = Keyword.fetch!(@supported_indexes, String.to_atom(indexName))
def new(index_name, query) when index_name in @supported_index_keys do
algolia_index = Keyword.fetch!(@supported_indexes, String.to_atom(index_name))

%__MODULE__{
indexName: algoliaIndex,
indexName: algolia_index,
query: query,
attributesToHighlight: highlight(indexName)
attributesToHighlight: highlight(index_name)
}
|> with_hit_size(indexName)
|> with_facet_filters(indexName)
|> with_hit_size(index_name)
|> with_facet_filters(index_name)
end

defp highlight("routes"), do: ["route.name", "route.long_name"]
Expand Down
8 changes: 4 additions & 4 deletions lib/dotcom_web/controllers/fare_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ defmodule DotcomWeb.FareController do
|> Fares.Repo.for_fare_class(duration: :single_trip, reduced: nil)
|> Fares.Format.summarize(Fares.Format.mode_type_for_fare_class(fare_class))
|> Enum.map(fn summary ->
changedName = format_name(summary)
{changedName, Fares.Summary.price_range(summary)}
changed_name = format_name(summary)
{changed_name, Fares.Summary.price_range(summary)}
end)
end)

Expand All @@ -155,8 +155,8 @@ defmodule DotcomWeb.FareController do

# capitalize lowercases every word after the first word in `name`. This fixes the one
# edge case for Commuter Rail
capitalizedName = String.capitalize(name)
String.replace(capitalizedName, "Commuter rail", "Commuter Rail")
capitalized_name = String.capitalize(name)
String.replace(capitalized_name, "Commuter rail", "Commuter Rail")
end

# Use the route mode to determine the display fare. e.g. instead of the 23 bus
Expand Down
4 changes: 2 additions & 2 deletions test/algolia/request_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ defmodule Algolia.Query.RequestTest do

test "changes facetFilters param based on index" do
assert %Request{params: %{"facetFilters" => [[]]}} = Request.new("routes", "")
assert %Request{params: %{"facetFilters" => facetFilters}} = Request.new("drupal", "")
refute facetFilters == [[]]
assert %Request{params: %{"facetFilters" => facet_filters}} = Request.new("drupal", "")
refute facet_filters == [[]]
end
end

Expand Down

0 comments on commit 7a86d16

Please sign in to comment.