Skip to content
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

Refactor/singleton 1 #13269

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
104dc71
fix: Hopefully fixed the build of the cpp-example on windows systems
chrisdutz Aug 17, 2023
0db1a8f
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 17, 2023
1bdc2cf
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 18, 2023
0ea9e78
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 21, 2023
4b79d7a
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 31, 2023
5e54115
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 31, 2023
b16c9a0
Merge remote-tracking branch 'upstream/master'
chrisdutz Sep 5, 2023
d162a48
Merge branch 'apache:master' into master
chrisdutz Sep 6, 2023
13ef12e
Merge remote-tracking branch 'upstream/master'
chrisdutz Sep 7, 2023
4f22e11
Merge branch 'apache:master' into master
chrisdutz Sep 8, 2023
bbbf3e3
Merge remote-tracking branch 'upstream/master'
chrisdutz Sep 14, 2023
8a56b00
Merge remote-tracking branch 'upstream/master'
chrisdutz Sep 19, 2023
2ad77a6
Merge remote-tracking branch 'upstream/master'
chrisdutz Oct 17, 2023
383d101
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 1, 2023
f6f4ac6
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 7, 2023
e1c6f72
fix: Increase the timeout even more to finally make the build succeed.
chrisdutz Nov 7, 2023
8a18cf3
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 9, 2023
8b9075a
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 29, 2023
a6c11a0
Merge remote-tracking branch 'upstream/master'
chrisdutz Nov 29, 2023
18ccb78
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 3, 2024
1c5d175
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 8, 2024
d650a88
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 9, 2024
c84581a
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 23, 2024
f6e5f1c
Merge remote-tracking branch 'upstream/master'
chrisdutz Jan 30, 2024
bf64c2f
Merge remote-tracking branch 'upstream/master'
chrisdutz Feb 5, 2024
66680d1
Merge remote-tracking branch 'upstream/master'
chrisdutz Mar 13, 2024
9e62ab3
Merge remote-tracking branch 'upstream/master'
chrisdutz Mar 14, 2024
24f7842
fix: Fix the build.
chrisdutz Mar 14, 2024
9012fa9
Merge remote-tracking branch 'refs/remotes/origin/master'
chrisdutz Apr 15, 2024
9e5b39a
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Apr 15, 2024
055fc0d
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Apr 18, 2024
c08a231
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Apr 22, 2024
1134199
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 2, 2024
a835848
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 17, 2024
ac5791a
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 24, 2024
9d7e9bd
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 27, 2024
af5cbcc
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz May 28, 2024
4e32ab5
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 4, 2024
2bb282f
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 7, 2024
8e6f9b3
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 11, 2024
ff8f7d2
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 12, 2024
d4cc59d
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 13, 2024
9124725
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jun 25, 2024
2510143
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jul 10, 2024
7b678c7
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jul 11, 2024
8153f1e
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Jul 31, 2024
77f7acf
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Aug 5, 2024
9ced664
Merge remote-tracking branch 'refs/remotes/upstream/master'
chrisdutz Aug 5, 2024
7deb8ed
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 14, 2024
86c019a
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 14, 2024
1a0df2f
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 14, 2024
8fd8f8a
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 19, 2024
b836fcb
Merge remote-tracking branch 'upstream/master'
chrisdutz Aug 21, 2024
e21c528
feat: Added some jqassistant checks to the build
chrisdutz Aug 21, 2024
6905c8e
feat: Updated the definition of some singleton concepts
chrisdutz Aug 21, 2024
4f8b6c0
feat: Added a singleton client concept
chrisdutz Aug 21, 2024
c006a63
feat: Added a singleton client concept
chrisdutz Aug 21, 2024
633723c
feat: Added new USES_SINGLETON relationships between Singletons and t…
chrisdutz Aug 22, 2024
8381f97
feat: Polished the reports and queries a bit.
chrisdutz Aug 22, 2024
4198888
feat: Moved the execution into a separate profile
chrisdutz Aug 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .jqassistant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# documentation https://jqassistant.github.io/jqassistant/2.4.0/
jqassistant:
analyze:
groups:
- singleton
execute-applied-concepts: true
142 changes: 142 additions & 0 deletions jqassistant/singletons.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<jqassistant-rules xmlns="http://schema.jqassistant.org/rule/v2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.jqassistant.org/rule/v2.2 https://jqassistant.github.io/jqassistant/current/schema/jqassistant-rule-v2.2.xsd">
<group id="singleton">
<includeConstraint refId="singleton:*"/>
</group>
<constraint id="singleton:">
<requiresConcept refId="singleton:PublicStaticMethodSingleton"/>
<requiresConcept refId="singleton:PublicStaticPropertySingleton"/>
<requiresConcept refId="singleton:PublicStaticMethodSingletonClient"/>
<requiresConcept refId="singleton:PublicStaticPropertySingletonClient"/>
<description>No singletons should be used.</description>
<cypher><![CDATA[
MATCH
(type:Type) -[:DECLARES]-> (method:Method) -[invocation:INVOKES]-> (:Method) <-[:DECLARES]- (singleton:Type:Singleton)
WHERE
singleton:SingletonClient
RETURN
type as Type, invocation as Invocation, singleton as SingletonDefinition
ORDER BY
invocation.lineNumber
]]></cypher>
<report primaryColumn="Invocation"/>
</constraint>
<!-- Addresses all types that provide singleton functionality, no matter which type of access path they use -->
<concept id="singleton:Singleton">
<description>Identifies singletons as a general concept.</description>
<cypher><![CDATA[
MATCH
(singleton:Type:Singleton)
RETURN
singleton
ORDER BY
singleton.fqn
]]></cypher>
</concept>
<!-- Detects singleton patterns where a type has a "public static getInstance()" method which returns the same type as the class itself -->
<concept id="singleton:PublicStaticMethodSingleton">
<providesConcept refId="singleton:Singleton"/>
<description>Identifies singletons that are accessed by a public static getInstance() method that returns the type of the main class.</description>
<cypher><![CDATA[
MATCH
(singleton:Class:Type) -[:DECLARES]-> (method:Method) -[:RETURNS]-> (singleton) WHERE NOT (method) -[:HAS]-> (:Parameter) AND method.static = true AND method.visibility = "public"
SET
method:Singleton:PublicStaticMethod
RETURN
singleton
ORDER BY
singleton.fqn
]]></cypher>
</concept>
<!-- Detects singleton patterns where a type has a "public static" instance variable of the same type as the class itself -->
<concept id="singleton:PublicStaticPropertySingleton">
<providesConcept refId="singleton:Singleton"/>
<description>Identifies singletons that are accessed by a public static property of the type of the main class.</description>
<cypher><![CDATA[
MATCH
(singleton:Class:Type) -[:DECLARES*]-> (field:Field) -[:OF_TYPE]-> (singleton) WHERE field.static = true AND field.visibility = "public"
SET
field:Singleton:PublicStaticField
RETURN
singleton
ORDER BY
singleton.fqn
]]></cypher>
</concept>
<!-- Addresses all types that use a singleton, no matter which type of access path they use -->
<concept id="singleton:SingletonClient">
<description>Identifies singleton client as a general concept.</description>
<cypher><![CDATA[
MATCH
(client:Type:SingletonClient)
RETURN
DISTINCT client
ORDER BY
client.fqn
]]></cypher>
</concept>
<!--
Marks types as SingletonClients, that call "getInstance()" methods of types marked as "Singleton"
and adds a USES_SINGLETON relation between client and singleton.
-->
<concept id="singleton:PublicStaticMethodSingletonClient">
<providesConcept refId="singleton:SingletonClient"/>
<requiresConcept refId="singleton:PublicStaticMethodSingleton"/>
<requiresConcept refId="singleton:PublicStaticPropertySingleton"/>
<description>Identifies classes that accesses a singleton via public static getInstance() method.</description>
<cypher><![CDATA[
MATCH
(client:Type:Class) -[:DECLARES*]-> (whatever) -[:INVOKES]-> (singleton:Singleton)
SET
client:SingletonClient:PublicStaticMethod
MERGE
(client) -[:USES_SINGLETON]-> (singleton)
RETURN
DISTINCT client, singleton
ORDER BY
client.fqn
]]></cypher>
</concept>
<!--
Marks types as SingletonClients, that read the public static singleton variable of types marked as "Singleton"
and adds a USES_SINGLETON relation between client and singleton.
-->
<concept id="singleton:PublicStaticPropertySingletonClient">
<providesConcept refId="singleton:SingletonClient"/>
<requiresConcept refId="singleton:PublicStaticMethodSingleton"/>
<requiresConcept refId="singleton:PublicStaticPropertySingleton"/>
<description>Identifies classes that accesses a singleton via public static property.</description>
<cypher><![CDATA[
MATCH
(client:Type:Class) -[:DECLARES*]-> (whatever) -[:READS]-> (singleton:Singleton)
SET
client:SingletonClient:PublicStaticField
MERGE
(client) -[:USES_SINGLETON]-> (singleton)
RETURN
DISTINCT client, singleton
ORDER BY
client.fqn
]]></cypher>
</concept>
</jqassistant-rules>
28 changes: 28 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1906,5 +1906,33 @@
<enforcer.skip>false</enforcer.skip>
</properties>
</profile>
<!--
This profile enables JQAssistant in order to do a full structural analysis of IoTDB.
It stores the raw data in a local Neo4J database, which you can access after the build
with "mvn jqassistant:server" and then using any web-browser to query the data.
This profile also generates a report about singleton usage in "target/site/jqassistant.html".
-->
<profile>
<id>with-architectural-analysis</id>
<build>
<plugins>
<plugin>
<groupId>com.buschmais.jqassistant</groupId>
<artifactId>jqassistant-maven-plugin</artifactId>
<version>2.5.0-M1</version>
<executions>
<execution>
<goals>
<!-- Analyses the codebase and stores data in Neo4j -->
<goal>scan</goal>
<!-- Executes the analysis tasks defined in the "jqassistant" directory -->
<goal>analyze</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
34 changes: 34 additions & 0 deletions singletons.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->

== Expressions

List names of classes and methods or properties for accessing the singleton (Uses the "singleton" concept):

MATCH (parent:Type:Class) -[:DECLARES*]-> (s:Singleton) RETURN parent.fqn, s.name

List all classes, that access a singleton via public static property:

MATCH (client:Type:Class) -[:DECLARES*]-> (whatever) -[:READS]->(s:Singleton) RETURN DISTINCT client.fqn ORDER BY client.fqn

List all classes, that access a singleton via public static method:

MATCH (client:Type:Class) -[:DECLARES*]-> (whatever) -[:INVOKES]->(s:Singleton) RETURN DISTINCT client.fqn ORDER BY client.fqn
Loading