Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0027432Openbravo ERPA. Platformpublic2014-08-23 13:282016-06-28 16:06
shuehner 
Sanjota 
normaltrivialhave not tried
closedfixed 
5
 
3.0PR16Q3 
aferraz
Core
No
0027432: Cleanup unused variables in pl-functions & triggers
There are quite a few variables declared in in pl-functions & -triggers which are never used.

Those should be cleaned up.

Note: found using static analysis using plpgsql_check
Run plpgsql_check_function on all functions + trigger
And review output.
Delete the unused variables.
No tags attached.
related to defect 0030720 closed shuehner Cleanup unused variables in pl-functions & triggers (platform part) 
related to defect 0033422 closed Sanjota Static code analysis: triggers 
? 27432_v2.hgexport (65,500) 2015-09-02 10:12
https://issues.openbravo.com/file_download.php?file_id=8411&type=bug
Issue History
2014-08-23 13:28shuehnerNew Issue
2014-08-23 13:28shuehnerAssigned To => shuehner
2014-08-23 13:28shuehnerModules => Core
2014-08-23 13:28shuehnerTriggers an Emergency Pack => No
2015-08-26 19:58shuehnerFile Added: 27432.hgexport
2015-09-01 16:22shuehnerIssue cloned0030720
2015-09-01 16:22shuehnerRelationship addedrelated to 0030720
2015-09-02 10:05shuehnerNote Added: 0080010
2015-09-02 10:12shuehnerFile Added: 27432_v2.hgexport
2015-09-02 10:12shuehnerFile Deleted: 27432.hgexport
2015-09-02 10:12shuehnerNote Added: 0080012
2016-06-06 18:36aferrazAssigned Toshuehner => Sanjota
2016-06-13 17:33SanjotaNote Added: 0087206
2016-06-13 17:37SanjotaNote Edited: 0087206bug_revision_view_page.php?bugnote_id=0087206#r12356
2016-06-14 11:09SanjotaNote Edited: 0087206bug_revision_view_page.php?bugnote_id=0087206#r12363
2016-06-14 12:03SanjotaNote Edited: 0087206bug_revision_view_page.php?bugnote_id=0087206#r12368
2016-06-27 16:45SanjotaStatusnew => scheduled
2016-06-28 09:52hgbotCheckin
2016-06-28 09:52hgbotNote Added: 0088005
2016-06-28 09:52hgbotStatusscheduled => resolved
2016-06-28 09:52hgbotResolutionopen => fixed
2016-06-28 09:52hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/a8a6d8bd52e5bc439abf179aa9d6166c4ec11258 [^]
2016-06-28 09:52hgbotCheckin
2016-06-28 09:52hgbotNote Added: 0088006
2016-06-28 09:57aferrazNote Added: 0088007
2016-06-28 12:53aferrazNote Edited: 0088007bug_revision_view_page.php?bugnote_id=0088007#r12548
2016-06-28 12:56aferrazReview Assigned To => aferraz
2016-06-28 12:56aferrazNote Added: 0088046
2016-06-28 12:56aferrazStatusresolved => closed
2016-06-28 12:56aferrazFixed in Version => 3.0PR16Q3
2016-06-28 16:06hudsonbotCheckin
2016-06-28 16:06hudsonbotNote Added: 0088057
2016-06-28 16:06hudsonbotCheckin
2016-06-28 16:06hudsonbotNote Added: 0088058
2016-07-05 10:21SanjotaRelationship addedrelated to 0033422

Notes
(0080010)
shuehner   
2015-09-02 10:05   
Notes for review:
All cases have been found by plpgsql_check static analysis tool but then also manually verified by checking the .xml source file in an editor.

And for each case search for the allegedly unused variable in all file to verify it is not used at all

That same procedure can be used to verify that the deleted variables are in fact not used.

NOTE: search must be done case-insensitive as pl does allow that when using variables.
(0080012)
shuehner   
2015-09-02 10:12   
Updated attachment to track the remaining ones not already fixed in 30720
(0087206)
Sanjota   
2016-06-13 17:33   
(edited on: 2016-06-14 12:03)
Test Plan:
Found datatype bug using static analysis using plpgsql_check and fixed the same.
Removed unused variables and changed datatype mismatches.


Note: There are few variables which are used in the same function but the tool display as unused variables. Following are the list for same.
1)c_commission_process :unused variable "type_ref"
2)c_invoice_post :unused variable "v_processed"
3)c_yearperiods :unused variable "v_monthno"
4)m_inout_post :unused variable "v_qtyaux"
5)m_pricelist_create :relation "c_temp_selection" does not exist
                            Query: DELETE FROM C_TEMP_Selection
6)ad_org_chk_doc_payments :unused variable "type_ref"
7)ad_org_chk_documents :unused variable "type_ref"

(0088005)
hgbot   
2016-06-28 09:52   
Repository: erp/devel/pi
Changeset: a8a6d8bd52e5bc439abf179aa9d6166c4ec11258
Author: Sanjota <sanjota.nelagi <at> promantia.com>
Date: Mon Jun 13 20:23:15 2016 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/a8a6d8bd52e5bc439abf179aa9d6166c4ec11258 [^]

Fixes issue 27432: Cleanup unused variables in pl-functions & triggers

There are quite a few variables declared in in pl-functions & -triggers which are never used, found using static analysis using plpgsql_check. Clean those variables

---
M src-db/database/model/functions/A_ASSET_CREATE.xml
M src-db/database/model/functions/A_ASSET_POST.xml
M src-db/database/model/functions/C_AGING_GET_SCOPE.xml
M src-db/database/model/functions/C_BANKSTATEMENT_POST.xml
M src-db/database/model/functions/C_BP_GROUP_ACCT_COPY.xml
M src-db/database/model/functions/C_CASH_POST.xml
M src-db/database/model/functions/C_CHANGEPROJECTSTATUS.xml
M src-db/database/model/functions/C_CHANGEPROJECTSTATUSTOORDER.xml
M src-db/database/model/functions/C_CLOSEPROJECT.xml
M src-db/database/model/functions/C_CURRENCY_CONVERT.xml
M src-db/database/model/functions/C_CURRENCY_CONVERT_RATE.xml
M src-db/database/model/functions/C_CURRENCY_RATE.xml
M src-db/database/model/functions/C_DB_PERCENTAGE_PAID.xml
M src-db/database/model/functions/C_DP_MANAGEMENT_POST.xml
M src-db/database/model/functions/C_GENERATEPOFROMPROJECT.xml
M src-db/database/model/functions/C_GENERATESOFROMPROJECT.xml
M src-db/database/model/functions/C_GENERATESOFROMPROJECTPHASE.xml
M src-db/database/model/functions/C_GET_IBAN_DISPLAYED_ACCOUNT.xml
M src-db/database/model/functions/C_GET_NET_PRICE_FROM_GROSS.xml
M src-db/database/model/functions/C_INVOICELINETAX_INSERT.xml
M src-db/database/model/functions/C_INVOICELINETAX_ROUNDING.xml
M src-db/database/model/functions/C_INVOICE_POST.xml
M src-db/database/model/functions/C_ORDERLINETAX_INSERT.xml
M src-db/database/model/functions/C_ORDERLINETAX_ROUNDING.xml
M src-db/database/model/functions/C_ORDER_POST1.xml
M src-db/database/model/functions/C_ORDER_PO_CREATE.xml
M src-db/database/model/functions/C_PAYINADVANCE_CREATE.xml
M src-db/database/model/functions/C_PERIOD_PROCESS.xml
M src-db/database/model/functions/C_PROJECT_GENERATE.xml
M src-db/database/model/functions/C_REMITTANCE_POST.xml
M src-db/database/model/functions/C_SETTLEMENT_POST.xml
M src-db/database/model/functions/C_TAXPAYMENT_POST.xml
M src-db/database/model/functions/C_TAX_GET_LEVEL.xml
M src-db/database/model/functions/C_VALIDCOMBINATION_CLONE.xml
M src-db/database/model/functions/FACT_ACCT_RESET.xml
M src-db/database/model/functions/MA_COPY_VERSION.xml
M src-db/database/model/functions/MA_GLOBALUSE_DISTRIBUTE.xml
M src-db/database/model/functions/MA_MAINTENANCE_SCHEDULE.xml
M src-db/database/model/functions/MA_MEASURE_SHIFT_EXPLODE.xml
M src-db/database/model/functions/MA_MEASURE_TIME_EXPLODE.xml
M src-db/database/model/functions/MA_PC_CASE_CREATE.xml
M src-db/database/model/functions/MA_PRODUCTIONRUN_STANDARD.xml
M src-db/database/model/functions/MA_PRODUCTION_COST.xml
M src-db/database/model/functions/MA_PRODUCTION_COST_GENERATE.xml
M src-db/database/model/functions/MA_STANDARD_COST_SEQUENCE.xml
M src-db/database/model/functions/MRP_PROCESSPLAN.xml
M src-db/database/model/functions/MRP_PROCESSPLAN_PLAN.xml
M src-db/database/model/functions/MRP_PROCESSPLAN_RECALCULATE.xml
M src-db/database/model/functions/MRP_PROCESSPLAN_RECALCULATE0.xml
M src-db/database/model/functions/MRP_PRODUCTION_RUN.xml
M src-db/database/model/functions/MRP_PURCHASEORDER.xml
M src-db/database/model/functions/MRP_PURCHASEPLAN.xml
M src-db/database/model/functions/MRP_PURCHASE_RUN.xml
M src-db/database/model/functions/MRP_REQUISITION.xml
M src-db/database/model/functions/MRP_RUN_EXPLODE.xml
M src-db/database/model/functions/MRP_RUN_INITIALIZE.xml
M src-db/database/model/functions/MRP_WORKREQUIREMENT.xml
M src-db/database/model/functions/M_GENERATE_AVERAGE_COSTS.xml
M src-db/database/model/functions/M_GENERATE_STANDARD_COSTS.xml
M src-db/database/model/functions/M_GET_OFFERS_NAME.xml
M src-db/database/model/functions/M_GET_PARETO_ABC.xml
M src-db/database/model/functions/M_GET_PARETO_ABC_LEGACY.xml
M src-db/database/model/functions/M_GET_STOCK.xml
M src-db/database/model/functions/M_GET_STOCK_PARAM.xml
M src-db/database/model/functions/M_INOUTEXPLODEBOMNOTSTOCK.xml
M src-db/database/model/functions/M_INOUT_CANCEL.xml
M src-db/database/model/functions/M_INOUT_CREATE.xml
M src-db/database/model/functions/M_INOUT_CREATEINVOICE.xml
M src-db/database/model/functions/M_INOUT_POST.xml
M src-db/database/model/functions/M_INTERNAL_CONSUMPTION_POST1.xml
M src-db/database/model/functions/M_INVENTORY_POST.xml
M src-db/database/model/functions/M_MOVEMENT_POST.xml
M src-db/database/model/functions/M_RAPPEL_INVOICE_CREATE.xml
M src-db/database/model/functions/M_REQUISITION_CREATEPO.xml
M src-db/database/model/functions/M_RESERVATION_REALLOCATE.xml
M src-db/database/model/functions/M_UNIQUELOCATOR_RULE.xml
M src-db/database/model/functions/M_UNIQUELOCATOR_RULE_PARAM.xml
M src-db/database/model/functions/M_UPDATE_PARETO_PRODUCT.xml
M src-db/database/model/functions/M_UPDATE_PARETO_PRODUCT_LEGACY.xml
M src-db/database/model/functions/S_TIMEEXPENSE_POST.xml
---
(0088006)
hgbot   
2016-06-28 09:52   
Repository: erp/devel/pi
Changeset: a3c288cd3d2fc4c1eaec67cb2f98dde321d36e42
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Mon Jun 27 18:59:29 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/a3c288cd3d2fc4c1eaec67cb2f98dde321d36e42 [^]

Related to issue 27432: Code review improvements

---
M modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml
M modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_ISPAYMENTCONFIRMED.xml
M src-db/database/model/functions/C_INVOICE_POST.xml
M src-db/database/model/functions/C_PROJECT_GENERATE.xml
M src-db/database/model/functions/C_YEARPERIODS.xml
M src-db/database/model/functions/M_COPY_PRODUCT_TEMPLATE.xml
M src-db/database/model/functions/M_INOUT_POST.xml
---
(0088007)
aferraz   
2016-06-28 09:57   
(edited on: 2016-06-28 12:53)
After code review, query still retrieving following results:

- ad_org_chk_doc_payments: warning:00000:24:DECLARE:unused variable "type_ref"
- ad_org_chk_documents: warning:00000:24:DECLARE:unused variable "type_ref"
- c_commission_process: warning:00000:175:DECLARE:unused variable "type_ref"
- m_pricelist_create: error:42P01:171:SQL statement:relation "c_temp_selection" does not exist
- m_pricelist_create: Query: DELETE FROM C_TEMP_Selection
- m_pricelist_create: --

(0088046)
aferraz   
2016-06-28 12:56   
Code review OK
(0088057)
hudsonbot   
2016-06-28 16:06   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/865878a5d292 [^]
Maturity status: Test
(0088058)
hudsonbot   
2016-06-28 16:06   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/865878a5d292 [^]
Maturity status: Test