8000 Inspections: Implement Cognifide AEM SonarQube rules as Intellij Inspections · Issue #146 · aemtools/aemtools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Inspections: Implement Cognifide AEM SonarQube rules as Intellij Inspections #146
Open
@deeprim

Description

@deeprim

Create inspections similar to AEM SonarQube rules by Cognifide

Good practices

  • AEM-1 Inspections: AEM-1 & AEM-2 #148: Use predefined constant in annotation instead of hardcoded value.
    • Use constants available in AEM instead of repeating inline literals
  • AEM-2 Inspections: AEM-1 & AEM-2 #148: Use predefined constant instead of hardcoded value.
    • Use constants available in AEM instead of repeating inline literals.
  • AEM-8 Prefer cleaner @SlingServlet annotation.
    • Prefer cleaner @SlingServlet annotation over @Properties approach. Do not mix up both approaches.
  • AEM-14 Using http literal hardcoded makes it difficult to switch to https later on.
    • We should not use http as a literal in our projects because if we want to switch to https, our code will be not ready.
  • AEM-15 Usage of synchronized keyword should be avoided if possible.
    • Usage of synchronized keyword should be avoided if possible. Check if using synchronized can be replaced with more sophisticated solution.
  • AEM-17 No mutator methods invoked on ModifiableValueMap
    • ModifiableValueMap should be replaced by ValueMap if no mutator methods are invoked.

Possible bugs

  • AEM-3 Inspections: AEM-3 #159 Non-thread safe object used as a field of Servlet/Filter etc.
    • It if not safe to keep session based object as a field in Servlet or Filter. Rule checks for the occurrence of any instance or static fields of following types:
      • org.apache.sling.api.resource.ResourceResolver
      • javax.jcr.Session
      • com.day.cq.wcm.api.PageManager
      • com.day.cq.wcm.api.components.ComponentManager
      • com.day.cq.wcm.api.designer.Designer
      • com.day.cq.dam.api.AssetManager
      • com.day.cq.tagging.TagManager
      • com.day.cq.security.UserManager
      • org.apache.jackrabbit.api.security.user.Authorizable
      • org.apache.jackrabbit.api.security.user.User
      • org.apache.jackrabbit.api.security.user.UserManager
  • AEM-6 Inspections: AEM 6 implementation #162 ResourceResolver should be closed in finally block.
    • According to its Javadoc, Resource Resolver has a life cycle which begins with the creation of the Resource Resolver using any of the factory methods and ends with calling the close method. It is very important to call the close method once the resource resolver is not used any more to ensure any system resources are properly clean up.
  • AEM-7 Session should be logged out in finally block.
    • Manually created javax.jcr.Session should be logged out after it is no longer needed. The logout method releases all resources associated with Session.
  • AEM-11 Do not use deprecated administrative access methods
    • Administrative access to the resource tree and JCR Repository by means of usage of ResourceResolverFactory.getAdministrativeResourceResolver and SlingRepository.loginAdministrative has been deprecated. Use ResourceResolverFactory.getServiceResourceResolver or SlingRepository.loginServicer respectively.

Sling Models related

  • AEM-16 Inspections: AEM-16 #157 Optional is defined as DefaultInjectionStrategy
    • Usage of @Optional annotation is redundant, when defaultInjectionStrategy is OPTIONAL.

Description of inspection is taken from Cognifide/AEM-Rules-for-SonarQube github page

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0