{"title":"CodeCop Warning AA0150","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/analyzers/codecop-aa0150/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0150, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0150","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Do not declare parameters by reference if their values are never changed.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"CodeCop Warning AA0150","slug":"codecop-warning-aa0150","at":0,"chars":2001},{"level":2,"title":"Description","slug":"description","at":99,"chars":89},{"level":2,"title":"Reason for the rule","slug":"reason-for-the-rule","at":188,"chars":295},{"level":2,"title":"Bad code example 1","slug":"bad-code-example-1","at":483,"chars":312},{"level":2,"title":"Good code example 1","slug":"good-code-example-1","at":795,"chars":172},{"level":2,"title":"Bad code example 2","slug":"bad-code-example-2","at":967,"chars":140},{"level":2,"title":"Good code example 2","slug":"good-code-example-2","at":1107,"chars":137},{"level":2,"title":"Remarks","slug":"remarks","at":1244,"chars":620},{"level":2,"title":"Related information","slug":"related-information","at":1864,"chars":137}],"text":"# CodeCop Warning AA0150\nDo not declare parameters by reference if their values are never changed.\n## Description\nDo not declare parameters by reference if their values are never changed.\n## Reason for the rule\nDefining a parameter as passed by reference and not actually changing it may lead to an unexpected variable value if the variable is later changed in the method. In addition, other developers may think that the value is changed in the method, eventhough that is not true.\n## Bad code example 1\nThe following example illustrates the developer's error - forgot to remove var property of MyList in Method1, after redesigning Method2.\n```al\nprocedure Method1(var MyB: boolean)\nbegin\nMethod2(MyB);\nend;\n\nprocedure Method2(MyC: boolean)\nvar\nsomeVar: boolean;\nbegin\nsomeVar := MyC;\nend;\n```\n## Good code example 1\n```al\nprocedure Method1(MyB: boolean)\nbegin\nMethod2(MyB);\nend;\n\nprocedure Method2(MyC: boolean)\nvar\nsomeVar: boolean;\nbegin\nsomeVar := MyC;\nend;\n```\n## Bad code example 2\n```al\nprocedure Method1(var InvtValue: array[5] of Integer)\nvar\nMyInt: Integer;\nbegin\nMyInt := InvtValue[0];\nend;\n```\n## Good code example 2\n```al\nprocedure Method1(InvtValue: array[5] of Integer)\nvar\nMyInt: Integer;\nbegin\nMyInt := InvtValue[0];\nend;\n```\n## Remarks\nVariables of the following types are analyzed: Integer, BigInteger, Boolean, Byte, Char, Code, Date, DateTime, Decimal, Time, and Text. Also lists and arrays of above types are analyzed - these types should be changed with appropriate methods if they are passed by reference.\nEvent subscribers, Integration Events, and ConfirmHanders are also not analyzed. Parameters of the type List can be also changed following built-in methods: Add, AddRange, Set, Insert, Remove, RemoveAt, RemoveRange, Reverse. Arrays additionally changed by CompressArray and CopyArray. Also the Evaluate built-in method is supported.\n## Related information\nCodeCop Analyzer<codecop>\nGet Started with AL<../devenv-get-started>\nDeveloping Extensions<../devenv-dev-overview>"}