<commit_before>defmodule Weber.Route do

  @moduledoc """
    This module handles routing of weber web application.
    Use 'route' macros for declaring routing.

    @route on('/', Controller1, Action1)
        |> on ('/user/:name', Controller2, Action2)
        |> on ('/user/:name/delete', Controller2, Action1)
        |> otherwise (404, Controller2, ActionNotFound)
  """

  import Weber.Http.Url

  @doc """
    Router attribute
  """
  def on(path, controller, action) do
    [[path: path, controller: controller, action: action]]
  end

  def on(routesList, path, controller, action) do
    :lists.append(routesList, [[path: path, controller: controller, action: action]])
  end

  @doc """
    Router attribute
  """
  def otherwise(path, controller, action) do
    on(path, controller, action)
  end

  def otherwise(routesList, path, controller, action) do
    on(routesList, path, controller, action)
  end

  @doc """
    Match current url path. Is it web application route or not
  """
  def match_routes(path, routes) do
    parsed_path = getBinding(path)
    Enum.filter(routes, 
      fn(route) -> 
        [path: p, controller: _controller, action: _action] = route
          case p do
            "404" ->
              false
            _ ->
              parsed_route_path = getBinding(p)
              match_routes_helper(parsed_path, parsed_route_path)
          end
      end)
  end
  
  defp match_routes_helper([], []) do
    true
  end

  defp match_routes_helper([{_type, _path} | _parsed_path], []) do
    false
  end

  defp match_routes_helper([], [{_route_type, _route_path} | _parsed_route_path]) do
    false
  end

  defp match_routes_helper([{:param, _, key, val} | parsed_path], []) do
    true
  end
  
  defp match_routes_helper([{type, path} | parsed_path], [{route_type, route_path} | parsed_route_path]) do
    case type == route_type do
      true -> 
        case path == route_path do
          true -> match_routes_helper(parsed_path, parsed_route_path)
          false -> false
        end
      false -> 
        case route_type == :binding do
          true -> match_routes_helper(parsed_path, parsed_route_path)
          false -> false
        end
    end
  end

  defp match_routes_helper([{:param, _, key, val} | parsed_path], [{route_type, route_path} | parsed_route_path]) do
    true
  end

end<commit_msg>Warnings fix at lib/route.ex<commit_after>defmodule Weber.Route do

  @moduledoc """
    This module handles routing of weber web application.
    Use 'route' macros for declaring routing.

    @route on('/', Controller1, Action1)
        |> on ('/user/:name', Controller2, Action2)
        |> on ('/user/:name/delete', Controller2, Action1)
        |> otherwise (404, Controller2, ActionNotFound)
  """

  import Weber.Http.Url

  @doc """
    Router attribute
  """
  def on(path, controller, action) do
    [[path: path, controller: controller, action: action]]
  end

  def on(routesList, path, controller, action) do
    :lists.append(routesList, [[path: path, controller: controller, action: action]])
  end

  @doc """
    Router attribute
  """
  def otherwise(path, controller, action) do
    on(path, controller, action)
  end

  def otherwise(routesList, path, controller, action) do
    on(routesList, path, controller, action)
  end

  @doc """
    Match current url path. Is it web application route or not
  """
  def match_routes(path, routes) do
    parsed_path = getBinding(path)
    Enum.filter(routes, 
      fn(route) -> 
        [path: p, controller: _controller, action: _action] = route
          case p do
            "404" ->
              false
            _ ->
              parsed_route_path = getBinding(p)
              match_routes_helper(parsed_path, parsed_route_path)
          end
      end)
  end
  
  defp match_routes_helper([], []) do
    true
  end

  defp match_routes_helper([{_type, _path} | _parsed_path], []) do
    false
  end

  defp match_routes_helper([], [{_route_type, _route_path} | _parsed_route_path]) do
    false
  end

  defp match_routes_helper([{:param, _, _key, _val} | _parsed_path], []) do
    true
  end
  
  defp match_routes_helper([{type, path} | parsed_path], [{route_type, route_path} | parsed_route_path]) do
    case type == route_type do
      true -> 
        case path == route_path do
          true -> match_routes_helper(parsed_path, parsed_route_path)
          false -> false
        end
      false -> 
        case route_type == :binding do
          true -> match_routes_helper(parsed_path, parsed_route_path)
          false -> false
        end
    end
  end

  defp match_routes_helper([{:param, _, _key, _val} | _parsed_path], [{_route_type, _route_path} | _parsed_route_path]) do
    true
  end

end
{'fraction_non_alphanumeric': 0.11036225779275484, 'fraction_numerical': 0.005475989890480202, 'mean_word_length': 2.6985981308411215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '612161', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1500, 'n_words': 408}