Goal Find routine parameter names that contain the routine name. Names of routine parameters shouldn't contain the name of the routine. It makes the names too long. A routine cannot have two parameters with the same name.
Notes The query does not consider the routines that are a part of an extension. The query uses bold (b) tags to highlight the parts of parameter names that violate the suggestion. In the output data the query removes from the end of the routine name the numbers, which represent the object identifier of the routine in the system catalog.
Type Problem detection (Each row in the result could represent a flaw in the design)
Reliability High (Few or no false-positive results)
License MIT License
Fixing Suggestion Drop the routine and recreate it with the improved parameter names. Use a consistent style of naming.
Data Source INFORMATION_SCHEMA+system catalog
SQL Query
SELECT specific_schema AS routine_schema, 
regexp_replace(specific_name,'_[0-9]*$','') AS routine_name, 
pg_get_function_identity_arguments(translate(substring(specific_name,'_[0-9]+$'),'_','')::int::oid) AS parameters,
regexp_replace(parameter_name, regexp_replace(specific_name,'_[0-9]*$',''), '' || regexp_replace(specific_name,'_[0-9]*$','') || '','g') AS suspected_parameter
FROM information_schema.parameters
WHERE specific_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL) AND
parameter_name  ILIKE '%' ||  regexp_replace(specific_name,'_[0-9]*$','') || '%' AND NOT EXISTS (SELECT 1
FROM pg_catalog.pg_depend d inner join pg_catalog.pg_proc pc ON d.objid=pc.oid
WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_extension e WHERE d.refobjid=e.oid) AND
pc.proname || '_' || pc.oid = parameters.specific_name)
ORDER BY routine_schema, routine_name, parameters, parameter_name;

Collections

This query belongs to the following collections:

NameDescription
Find problems automaticallyQueries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
Categories

This query is classified under the following categories:

NameDescription
NamingQueries of this category provide information about the style of naming.
User-defined routinesQueries of this category provide information about the user-defined routines

Further reading and related materials:

Reference
The corresponding code problem in case of cleaning code is "Don’t Add Gratuitous Context". (Robert C. Martin, Clean Code)