|
27.06.2018, 13:11 | #1 |
Участник
|
waldo: AL Code Analysis Rules (Diagnostic Descriptors) – Updated
Источник: https://dynamicsuser.net/nav/b/waldo...iptors-updated
============== You might remember my post about the Code Analyzers Diagnostic Descriptors when it first came out. I’m very happy with this tool, as it avoids many mistakes, and it enforces some level of clean coding – which is never a bad thing ;-). Recently, the June update of the AL Language Extension was announced. I was sitting at a swimming pool in Bangkok – so what do you think I did? Exactly: It turned out I downloaded the wrong one :-). I needed to download from the daily build “bcinsider.azurecr.io/bcsandbox-master”. Anyway, when playing with it, I noticed there was an update on the analyzers as well – so it seemed interesting to update my previous blog in the descriptors, and let’s see what we have now. There are new descriptors, fixed descriptors, and even a whole new CodeCop, the UICop! AppSourceCop: This is the one that is use for extensions that will be used on AppSource – and on this one, nothing has changed. DiagnosticId Title Description MessageFormat Category Default Severety IsEnabledByDefault AS0001 Tables cannot be deleted. Tables cannot be deleted. Table ‘{0}’ has been deleted. Upgrade Error TRUE AS0002 Fields cannot be deleted. Fields cannot be deleted. Field ‘{0}’ has been deleted from table ‘{1}’. Upgrade Error TRUE AS0003 The previous version was not found. The previous version was not found. The previous version was not found. Name='{0}’, Publisher='{1}’, Version'{2}’ Upgrade Warning TRUE AS0004 Fields cannot change type. Fields cannot change type. Field ‘{0}’ has changed type from ‘{1}’ to ‘{2}’. Type changes are not allowed. Upgrade Error TRUE AS0005 Fields cannot change name. Fields cannot change name. Field ‘{0}’ has changed name to ‘{1}’. Name changes are not allowed. Upgrade Error TRUE AS0006 Tables cannot change name. Tables cannot change name. Table ‘{0}’ has changed name to ‘{1}’. Name changes are not allowed. Upgrade Error TRUE AS0007 Properties cannot change value. Properties cannot change value. The property ‘{0}’ has changed value. Value change is not allowed for this property. Upgrade Error TRUE AS0008 Keys cannot change name. Keys cannot change name. Key ‘{0}’ has changed name to ‘{1}’. Name changes are not allowed. Upgrade Error TRUE AS0009 Key fields cannot be changed. Key fields cannot be changed. Key ‘{0}’ has changed the key fields. Changes to the field list are not allowed. Upgrade Error TRUE AS0010 Keys cannot be deleted. Keys cannot be deleted. Key ‘{0}’ has been deleted. Key deletions is not allowed. Upgrade Error TRUE AS0011 A prefix is required A prefix is required The identifier ‘{0}’ must have the prefix ‘{1}’. Extensibility Error TRUE AS0012 A suffix is required A suffix is required The identifier ‘{0}’ must have the suffix ‘{1}’. Extensibility Error TRUE AS0013 The field identifier must be within the allowed range. The field identifier must be within the allowed range. The field identifier ‘{0}’ is not valid. It must be within the allowed range ‘{1}’ – ‘{2}’ Extensibility Error TRUE AS0014 The project manifest must contain the allocated identifier range. The project manifest must contain the allocated identifier range. The project manifest must contain the allocated identifier range. Extensibility Error TRUE CodeCop: The CodeCop is the one you should always align with. It’s the one that basically has general descriptors – which are always interesting. And in this one, we have two more “rules” we have to take into account – I put them in yellow. Both are quite logical, but now at least you have descriptors/rules/analysers that prevent you from doing things like that ;-). DiagnosticId Title Description MessageFormat Category Default Severety IsEnabledByDefault AA0001 There must be exactly one space character on each side of a binary operator such as := + – AND OR =. There must be exactly one space character on each side of a binary operator such as := + – AND OR =. The parameter comma operator however, should have no spaces. There must be exactly one space character on each side of ‘{0}’. Readability Warning TRUE AA0002 There must be no space character. There must be no space character between a unary operator and its argument. There must be no space character after ‘{0}’. Readability Warning TRUE AA0003 There must be exactly one space character between the NOT operator and its argument. There must be exactly one space character between the NOT operator and its argument. There must be exactly one space character after ‘{0}’. Readability Warning TRUE AA0005 Only use BEGIN..END to enclose compound statements. Only use BEGIN..END to enclose compound statements. Only use BEGIN..END to enclose compound statements. Readability Warning TRUE AA0008 Function calls should have parenthesis even if they do not have any parameters. Use parenthesis in a function call even if the function does not have any parameters. You must specify open and close parenthesis after ‘{0}’. Readability Warning TRUE AA0013 When BEGIN follows THEN, ELSE, DO, it should be on the same line, preceded by one space character. When BEGIN follows THEN, ELSE, DO, it should be on the same line, preceded by one space character. When BEGIN follows THEN, ELSE, DO, it should be on the same line, preceded by one space character. Readability Warning TRUE AA0018 The END, IF, REPEAT, FOR, WHILE, and CASE statement should always start a line. The END, IF, REPEAT, FOR, WHILE, and CASE statement should always start a line. The ‘{0}’ keyword should always start a line. Readability Warning TRUE AA0021 Variable declarations should be ordered by type. Variable declarations should be ordered by type. In general, object and complex variable types are listed first followed by simple variables. Variable declarations should be ordered by type. Readability Warning TRUE AA0022 Substitute the IF THEN ELSE structure with a CASE. An IF followed by two or more ELSE IF should be replaced with a CASE. Substitute the IF THEN ELSE structure with a CASE. Readability Warning TRUE AA0040 Avoid using nested WITH statements WITH statements should not be nested Avoid using nested WITH statements Readability Warning TRUE AA0074 TextConst variable names should have an approved suffix. TextConst variable names should have a suffix (an approved three-letter suffix: Msg, Tok, Err, Qst, Lbl, Txt) describing usage. TextConst variable ‘{0}’ must have a suffix from this list: Msg, Tok, Err, Qst, Lbl, Txt. Readability Warning TRUE AA0100 Do not have identifiers with quotes in the name. Do not have identifiers with quotes in the name. Do not have identifiers with quotes in the name. Design Warning TRUE AA0136 Do not write code that will never be hit. Do not write code that will never be hit. Unreachable code detected. Design Warning TRUE AA0137 Do not declare variables that are unused. Do not declare variables that are unused. Variable ‘{0}’ is unused in the method ‘{1}’. Design Warning TRUE AA0139 Do not assign a text to a target with smaller size. Do not assign a text to a target with smaller size. Possible overflow assigning ‘{0}’ to ‘{1}’. Design Warning TRUE AA0161 Only use ASSERTERROR in Test Codeunits. Only use ASSERTERROR in Test Codeunits. Only use ASSERTERROR in Test Codeunits. Design Warning TRUE AA0194 Only write actions that have an effect. Remember to specify either the ‘OnAction’ trigger or ‘RunObject’ property on an action. Remember to specify either the ‘OnAction’ trigger or ‘RunObject’ property on an action. Design Warning TRUE PerTenantExtensionCop: When you are doing customer development for a customer on the Business Central cloud, you are actually doing a “Per Tenant Customization”. The PerTenantExtensionsCop contains the rules to comply with. Nothing new, but there are a few fixes, as in the previous version, there was a hardcoded range of 50000..50099 in the first two descriptors.. . DiagnosticId Title Description MessageFormat Category Default Severety IsEnabledByDefault PTE0001 Object ID must be in free range. Object ID must be in free range. {0} ‘{1}’ has an ID of [{2}]. It must be between {3} and {4}. ObjectValidation Error TRUE PTE0002 Field ID must be in free range. Field ID must be in free range. Field ‘{0}’ has an ID of [{1}]. It must be between {2} and {3}. ObjectValidation Error TRUE PTE0003 Functions must not subscribe to CompanyOpen events. Functions must not subscribe to CompanyOpen events. Function {0} subscribes to {1}. ObjectValidation Error TRUE PTE0004 Table definitions must have a matching permission set. Table definitions must have a matching permission set. Table ‘{0}’ is missing a matching permission set. ObjectValidation Error TRUE PTE0005 Property ‘target’ has invalid value. ‘Internal’ is a reserved usage for the ‘target’ property. App.json ‘target’ property must not be set to ‘Internal’. PackageValidation Error TRUE PTE0006 Encryption key functions must not be invoked. Encryption key functions must not be invoked. Encryption key function ‘{0}’ is not allowed. PackageValidation Error TRUE PTE0007 Test assertion functions are not allowed in a non-test context. Test assertion functions are not allowed in a non-test context. Assertion function ‘{0}’ must not be invoked. PackageValidation Error TRUE PTE0008 Fields must use ApplicationArea property. Fields must use ApplicationArea property. Field with name ‘{0}’ must have a value for the ApplicationArea property. PackageValidation Error TRUE UICop: This is the new one! A whole new analyzer for you to use to be able to comply with the Web Client. DiagnosticId Title Description MessageFormat Category Default Severety IsEnabledByDefault AW0001 The Web client does not support displaying the Request page of XMLPorts. The Web client does not support displaying the Request page of XMLPorts. The Web client does not support displaying the Request page of the XMLPort ‘{0}’. WebClient Warning TRUE AW0002 The Web client does not support displaying both Actions and Fields in Cue Groups. Only Fields will be displayed. The Web client does not support displaying both Actions and Fields in Cue Groups. Only Fields will be displayed. The Web client does not support displaying both Actions and Fields in the Cue Group ‘{0}’. Only Fields will be displayed. WebClient Warning TRUE AW0003 The Web client does not support displaying Repeater controls containing Parts. The Web client does not support displaying Repeater controls containing Parts. The Web client does not support displaying Repeater controls containing Parts. WebClient Warning TRUE AW0004 A Blob cannot be used as a source expression for a page field. A Blob cannot be used as a source expression for a page field. A Blob cannot be used as a source expression for a page field. WebClient Warning TRUE Now you know! Enjoy! Источник: https://dynamicsuser.net/nav/b/waldo...iptors-updated
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|