-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix qhelp files #19707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix qhelp files #19707
Conversation
QHelp previews: cpp/ql/src/Metrics/Classes/CNumberOfFunctions.qhelpNumber of functions per classThis metric measures the number of functions in classes below this location in the tree. At a class level, it just measures the number of functions in the class itself. A class with too many functions is generally trying to do too much, either at the interface or implementation level or both. It can be difficult for readers to understand because there is a confusing list of operations. Such classes often lack cohesion and are prime candidates for refactoring. RecommendationClasses have too many functions for a variety of reasons, and the appropriate fix is different in each case:
References
cpp/ql/src/Metrics/Classes/CSizeOfAPI.qhelpSize of API per classThis metric measures the number of public functions for each public class. A class with too many public functions is generally trying to do too much, either at the interface or implementation level or both. It can be difficult for readers to understand because there is a confusing list of operations. Such classes often lack cohesion and are prime candidates for refactoring. RecommendationClasses have wide interfaces for a variety of different reasons, and the appropriate fix is different in each case:
References
java/ql/src/Metrics/RefTypes/TInheritanceDepth.qhelpType inheritance depthThis metric measures the inheritance depth of a reference type (e.g. a class). Whilst inheritance provides an avenue for code reuse, overly-deep class hierarchies can become a maintenance headache. Classes that inherit from many other classes can be brittle and hard to understand, because they depend on all of the classes further up the hierarchy. Conversely, changes to classes nearer the root of the hierarchy become harder and harder to make without breaking the descendants. In extreme cases, where the design of the hierarchy is seriously inappropriate, the class at the top of the hierarchy can become a 'blob' class: a storage point for anything that might be needed by one of its descendants. This is a key indicator that some serious refactoring is needed. RecommendationAs with many metrics, a high inheritance depth should be seen as an indicator that something is amiss, but further investigation will be needed to clarify the cause of the problem. Here are two possibilities:
For readers who are interested in this sort of approach, a good reference is [West]. References
java/ql/src/Metrics/RefTypes/TNumberOfCallables.qhelpNumber of methodsThis metric measures the number of methods in reference types below this location in the tree. At a type level, it just measures the number of methods in the type itself. A class with too many methods is generally trying to do too much, either at the interface or implementation level or both. It is common for the set of operations such a class provides to be diverse and wide-ranging, making it difficult for readers to understand. Such classes often lack cohesion and are prime candidates for refactoring. RecommendationClasses have too many methods for a variety of reasons, and the appropriate fix is different in each case:
References
java/ql/src/Metrics/RefTypes/TNumberOfFields.qhelpNumber of fieldsA class that contains a high number of fields may indicate the following problems:
RecommendationThe solution depends on the reason for the high number of fields:
ExampleIn the following example, class class Person {
private String m_firstName;
private String m_LastName;
private int m_houseNumber;
private String m_street;
private String m_settlement;
private Country m_country;
private Postcode m_postcode;
// ...
} This can be refactored by grouping fields that are part of the same abstraction into new classes class Name {
private String m_firstName;
private String m_lastName;
// ...
}
class Address {
private int m_houseNumber;
private String m_street;
private String m_settlement;
private Country m_country;
private Postcode m_postcode;
// ...
}
class Person {
private Name m_name;
private Address m_address;
// ...
} References
java/ql/src/Metrics/RefTypes/TSizeOfAPI.qhelpSize of a type's APIThis metric measures the number of public methods for each public class. A class with too many public methods is generally trying to do too much, either at the interface or implementation level or both. It can be difficult for readers to understand because there is a confusing list of operations. Such classes often lack cohesion and are prime candidates for refactoring. RecommendationClasses have wide interfaces for a variety of different reasons, and the appropriate fix is different in each case:
References
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes errors in multiple .qhelp
files by removing unsupported nested HTML (<ul>
, <li>
, <p>
) and replacing them with inline numbered formatting that the codeql generate query-help
command can handle.
- Replace nested lists with inline numbered items wrapped in HTML tags
- Remove unsupported
<p>
elements within list items - Align formatting across Java and C++ metric qhelp files
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
java/ql/src/Metrics/RefTypes/TSizeOfAPI.qhelp | Replaced <ul>/<li> block with <i> -wrapped numbered list |
java/ql/src/Metrics/RefTypes/TNumberOfFields.qhelp | Removed nested <p> around list item |
java/ql/src/Metrics/RefTypes/TNumberOfCallables.qhelp | Replaced <ul>/<li> block with <i> -wrapped numbered list |
java/ql/src/Metrics/RefTypes/TInheritanceDepth.qhelp | Converted <ul>/<li> to <p> -wrapped numbered paragraphs |
cpp/ql/src/Metrics/Classes/CSizeOfAPI.qhelp | Replaced <ul>/<li> block with <i> -wrapped numbered list |
cpp/ql/src/Metrics/Classes/CNumberOfFunctions.qhelp | Replaced <ul>/<li> block with <i> -wrapped numbered list |
Comments suppressed due to low confidence (1)
java/ql/src/Metrics/RefTypes/TInheritanceDepth.qhelp:31
- [nitpick] Inconsistent HTML formatting: this file uses
tags for numbered items while others use . Consider standardizing the approach across all qhelp files for consistency.
<p>1. A class and its superclass represent fundamentally the same abstraction.
<i> | ||
1. It may be possible to generalize some of the utility methods beyond the | ||
narrow context of the class in question -- by bundling them with the class, | ||
the class author reduces the scope for functionality reuse. | ||
</li> | ||
|
||
<li> | ||
It's usually impossible for the class author to know every possible | ||
2. It's usually impossible for the class author to know every possible | ||
operation that the user might want to perform on the class, so the public | ||
interface will inherently be incomplete. New utility methods will end up | ||
having a different syntax to the privileged public methods in the class, | ||
negatively impacting on code consistency. | ||
</li> | ||
</ul> | ||
</i> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Using tags to represent block-level numbered lists can be semantically confusing. Consider using plain markdown numbered lists (e.g., '1. ...\n2. ...') instead of HTML to improve clarity and compatibility.
Copilot uses AI. Check for mistakes.
Several qhelp files have errors when running the
codeql generate query-help --format=markdown <qhelp-file
command<ul>
, such as a second<ul>
or a<p>