logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: bfe626d5787ae546e2a96b8c4c621c09fea1332a
parent 94838ed941494fb6132086aa2cb3b5e65a00b08c
Author: Mark Felder <feld@feld.me>
Date:   Sun, 28 Jan 2024 16:32:50 -0500

Pleroma.Web.AdminAPI.ReportController: dialyzer errors

lib/pleroma/web/admin_api/controllers/report_controller.ex:48:no_return
Function update/2 has no local return.
________________________________________________________________________________
lib/pleroma/web/admin_api/controllers/report_controller.ex:70:call
The function call will not succeed.

Pleroma.Web.ControllerHelper.json_response(
  _conn :: %{
    :assigns => %{:user => _, _ => _},
    :body_params => %{:reports => _, _ => _},
    _ => _
  },
  :bad_request,
  _result :: [any()]
)

will never return since the 1st arguments differ
from the success typing arguments:

(
  %Plug.Conn{
    :adapter => {atom(), _},
    :assigns => %{atom() => _},
    :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :halted => boolean(),
    :host => binary(),
    :method => binary(),
    :owner => pid(),
    :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :path_info => [binary()],
    :path_params => %{
      binary() =>
        binary() | [binary() | [any()] | map()] | %{binary() => binary() | [any()] | map()}
    },
    :port => char(),
    :private => %{atom() => _},
    :query_params => %Plug.Conn.Unfetched{
      :aspect => atom(),
      binary() =>
        binary() | [binary() | [any()] | map()] | %{binary() => binary() | [any()] | map()}
    },
    :query_string => binary(),
    :remote_ip =>
      {byte(), byte(), byte(), byte()}
      | {char(), char(), char(), char(), char(), char(), char(), char()},
    :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
    :req_headers => [{binary(), binary()}],
    :request_path => binary(),
    :resp_body =>
      nil
      | binary()
      | maybe_improper_list(
          binary() | maybe_improper_list(any(), binary() | []) | byte(),
          binary() | []
        ),
    :resp_cookies => %{binary() => map()},
    :resp_headers => [{binary(), binary()}],
    :scheme => :http | :https,
    :script_name => [binary()],
    :secret_key_base => nil | binary(),
    :state =>
      :chunked | :file | :sent | :set | :set_chunked | :set_file | :unset | :upgraded,
    :status => nil | non_neg_integer()
  },
  atom() | 1..1_114_111,
  any()
)

________________________________________________________________________________
lib/pleroma/web/admin_api/controllers/report_controller.ex:72:call
The function call will not succeed.

Pleroma.Web.ControllerHelper.json_response(
  _conn :: %{
    :assigns => %{:user => _, _ => _},
    :body_params => %{:reports => _, _ => _},
    _ => _
  },
  :no_content,
  <<>>
)

will never return since the 1st arguments differ
from the success typing arguments:

(
  %Plug.Conn{
    :adapter => {atom(), _},
    :assigns => %{atom() => _},
    :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :halted => boolean(),
    :host => binary(),
    :method => binary(),
    :owner => pid(),
    :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :path_info => [binary()],
    :path_params => %{
      binary() =>
        binary() | [binary() | [any()] | map()] | %{binary() => binary() | [any()] | map()}
    },
    :port => char(),
    :private => %{atom() => _},
    :query_params => %Plug.Conn.Unfetched{
      :aspect => atom(),
      binary() =>
        binary() | [binary() | [any()] | map()] | %{binary() => binary() | [any()] | map()}
    },
    :query_string => binary(),
    :remote_ip =>
      {byte(), byte(), byte(), byte()}
      | {char(), char(), char(), char(), char(), char(), char(), char()},
    :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
    :req_headers => [{binary(), binary()}],
    :request_path => binary(),
    :resp_body =>
      nil
      | binary()
      | maybe_improper_list(
          binary() | maybe_improper_list(any(), binary() | []) | byte(),
          binary() | []
        ),
    :resp_cookies => %{binary() => map()},
    :resp_headers => [{binary(), binary()}],
    :scheme => :http | :https,
    :script_name => [binary()],
    :secret_key_base => nil | binary(),
    :state =>
      :chunked | :file | :sent | :set | :set_chunked | :set_file | :unset | :upgraded,
    :status => nil | non_neg_integer()
  },
  atom() | 1..1_114_111,
  any()
)

________________________________________________________________________________
lib/pleroma/web/admin_api/controllers/report_controller.ex:76:no_return
Function notes_create/2 has no local return.
________________________________________________________________________________
lib/pleroma/web/admin_api/controllers/report_controller.ex:89:call
The function call will not succeed.

Pleroma.Web.ControllerHelper.json_response(
  _conn :: %{
    :assigns => %{:user => _, _ => _},
    :body_params => %{:content => _, _ => _},
    _ => _
  },
  :no_content,
  <<>>
)

will never return since the 1st arguments differ
from the success typing arguments:

(
  %Plug.Conn{
    :adapter => {atom(), _},
    :assigns => %{atom() => _},
    :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :halted => boolean(),
    :host => binary(),
    :method => binary(),
    :owner => pid(),
    :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :path_info => [binary()],
    :path_params => %{
      binary() =>
        binary() | [binary() | [any()] | map()] | %{binary() => binary() | [any()] | map()}
    },
    :port => char(),
    :private => %{atom() => _},
    :query_params => %Plug.Conn.Unfetched{
      :aspect => atom(),
      binary() =>
        binary() | [binary() | [any()] | map()] | %{binary() => binary() | [any()] | map()}
    },
    :query_string => binary(),
    :remote_ip =>
      {byte(), byte(), byte(), byte()}
      | {char(), char(), char(), char(), char(), char(), char(), char()},
    :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
    :req_headers => [{binary(), binary()}],
    :request_path => binary(),
    :resp_body =>
      nil
      | binary()
      | maybe_improper_list(
          binary() | maybe_improper_list(any(), binary() | []) | byte(),
          binary() | []
        ),
    :resp_cookies => %{binary() => map()},
    :resp_headers => [{binary(), binary()}],
    :scheme => :http | :https,
    :script_name => [binary()],
    :secret_key_base => nil | binary(),
    :state =>
      :chunked | :file | :sent | :set | :set_chunked | :set_file | :unset | :upgraded,
    :status => nil | non_neg_integer()
  },
  atom() | 1..1_114_111,
  any()
)

________________________________________________________________________________
lib/pleroma/web/admin_api/controllers/report_controller.ex:91:call
The function call will not succeed.

Pleroma.Web.ControllerHelper.json_response(
  _conn :: %{
    :assigns => %{:user => _, _ => _},
    :body_params => %{:content => _, _ => _},
    _ => _
  },
  :bad_request,
  <<>>
)

will never return since the 1st arguments differ
from the success typing arguments:

(
  %Plug.Conn{
    :adapter => {atom(), _},
    :assigns => %{atom() => _},
    :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :halted => boolean(),
    :host => binary(),
    :method => binary(),
    :owner => pid(),
    :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :path_info => [binary()],
    :path_params => %{
      binary() =>
        binary() | [binary() | [any()] | map()] | %{binary() => binary() | [any()] | map()}
    },
    :port => char(),
    :private => %{atom() => _},
    :query_params => %Plug.Conn.Unfetched{
      :aspect => atom(),
      binary() =>
        binary() | [binary() | [any()] | map()] | %{binary() => binary() | [any()] | map()}
    },
    :query_string => binary(),
    :remote_ip =>
      {byte(), byte(), byte(), byte()}
      | {char(), char(), char(), char(), char(), char(), char(), char()},
    :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
    :req_headers => [{binary(), binary()}],
    :request_path => binary(),
    :resp_body =>
      nil
      | binary()
      | maybe_improper_list(
          binary() | maybe_improper_list(any(), binary() | []) | byte(),
          binary() | []
        ),
    :resp_cookies => %{binary() => map()},
    :resp_headers => [{binary(), binary()}],
    :scheme => :http | :https,
    :script_name => [binary()],
    :secret_key_base => nil | binary(),
    :state =>
      :chunked | :file | :sent | :set | :set_chunked | :set_file | :unset | :upgraded,
    :status => nil | non_neg_integer()
  },
  atom() | 1..1_114_111,
  any()
)

Diffstat:

Mlib/pleroma/web/admin_api/controllers/report_controller.ex4++--
Mlib/pleroma/web/api_spec/operations/admin/report_operation.ex6+++---
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/pleroma/web/admin_api/controllers/report_controller.ex b/lib/pleroma/web/admin_api/controllers/report_controller.ex @@ -45,7 +45,7 @@ defmodule Pleroma.Web.AdminAPI.ReportController do end end - def update(%{assigns: %{user: admin}, body_params: %{reports: reports}} = conn, _) do + def update(%{assigns: %{user: admin}, body_params: %{"reports" => reports}} = conn, _) do result = Enum.map(reports, fn report -> case CommonAPI.update_report_state(report.id, report.state) do @@ -73,7 +73,7 @@ defmodule Pleroma.Web.AdminAPI.ReportController do end end - def notes_create(%{assigns: %{user: user}, body_params: %{content: content}} = conn, %{ + def notes_create(%{assigns: %{user: user}, body_params: %{"content" => content}} = conn, %{ id: report_id }) do with {:ok, _} <- ReportNote.create(user.id, report_id, content), diff --git a/lib/pleroma/web/api_spec/operations/admin/report_operation.ex b/lib/pleroma/web/api_spec/operations/admin/report_operation.ex @@ -107,7 +107,7 @@ defmodule Pleroma.Web.ApiSpec.Admin.ReportOperation do request_body("Parameters", %Schema{ type: :object, properties: %{ - content: %Schema{type: :string, description: "The message"} + "content" => %Schema{type: :string, description: "The message"} } }), security: [%{"oAuth" => ["admin:write:reports"]}], @@ -199,9 +199,9 @@ defmodule Pleroma.Web.ApiSpec.Admin.ReportOperation do defp update_request do %Schema{ type: :object, - required: [:reports], + required: ["reports"], properties: %{ - reports: %Schema{ + "reports" => %Schema{ type: :array, items: %Schema{ type: :object,