Skip to content

Commit

Permalink
Create rule S6826: Sample rule that showcases potential image feature…
Browse files Browse the repository at this point in the history
…s in Sonar products (#3287)


Co-authored-by: loris-s-sonarsource <loris-s-sonarsource@users.noreply.github.com>
Co-authored-by: Loris Sierra <loris.sierra@sonarsource.com>
Co-authored-by: Loris S <91723853+loris-s-sonarsource@users.noreply.github.com>
Co-authored-by: Fred Tingaud <95592999+frederic-tingaud-sonarsource@users.noreply.github.com>
  • Loading branch information
5 people authored Nov 24, 2023
1 parent 5627673 commit 2730041
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 0 deletions.
98 changes: 98 additions & 0 deletions rules/S6826/java/asciidocs.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
:data-uri:

There are two AsciiDoc image macro types, block and inline. As with all macros,
the block and inline forms differ by the number of colons that follow the macro
name. The block form uses two colons (``++::++``), whereas the inline form only
uses one (``++:++``).

==== Block image macro

https://docs.asciidoctor.org/asciidoc/latest/macros/images/

----
// Example 1
Content in document.
image::image.png[]
Content in document
----

Content in document.

image::image.png[]

Content in document

include::lorem.adoc[]

==== Position and Frame Images

https://docs.asciidoctor.org/asciidoc/latest/macros/image-position/

==== Positioning attributes

----
// Example 1. A block image pulled to the right and centered within the block
image::image.png[Tiger,200,200,float="right",align="center"]
----

image::image.png[Tiger,200,200,float="right",align="center"]

include::lorem.adoc[]

----
// Example 2. An inline image pulled to the right of the paragraph text
image:image.png[Linux,150,150,float="right"]
You can find Linux everywhere these days!
----

image:image.png[Linux,150,150,float="right"]
You can find Linux everywhere these days!

include::lorem.adoc[]

==== Control the float

----
[.float-group]
--
[.left]
.Image A
image::image.png[A,240,180]
[.left]
.Image B
image::image.png[B,240,180]
--
Text below images.
----

[.float-group]
--
[.left]
.Image A
image::image.png[A,240,180]

[.left]
.Image B
image::image.png[B,240,180]
--

Text below images.

include::lorem.adoc[]

==== SVG images

https://docs.asciidoctor.org/asciidoc/latest/macros/image-svg/

----
image::icon.svg[Static,300]
----

image::icon.svg[Static,300]
1 change: 1 addition & 0 deletions rules/S6826/java/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rules/S6826/java/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions rules/S6826/java/lorem.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce a massa sit
amet lectus pellentesque auctor. Mauris efficitur egestas elementum. Morbi
placerat quam ut hendrerit porta. Nulla vitae orci sit amet elit pellentesque
interdum. Sed tincidunt ipsum at hendrerit ornare. Ut orci magna, fringilla et
finibus eu, consectetur vestibulum massa. Pellentesque habitant morbi tristique
senectus et netus et malesuada fames ac turpis egestas. Fusce sed lorem urna._

26 changes: 26 additions & 0 deletions rules/S6826/java/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"title": "This is a rule showcasing images in rules",
"type": "CODE_SMELL",
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"rspec-showcase"
],
"defaultSeverity": "Major",
"ruleSpecification": "RSPEC-6826",
"sqKey": "S6826",
"scope": "All",
"defaultQualityProfiles": ["Sonar way"],
"quickfix": "unknown",
"code": {
"impacts": {
"MAINTAINABILITY": "HIGH",
"RELIABILITY": "MEDIUM",
"SECURITY": "LOW"
},
"attribute": "CONVENTIONAL"
}
}
45 changes: 45 additions & 0 deletions rules/S6826/java/rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
== Why is this an issue?

This rule is not really a rule, but a demonstration of the images that can
appear in a rule description. The Asciidoc docs are copied, but only their code
samples.

A version containing links is available in
[the initial PR](https://github.com/SonarSource/rspec/blob/b83c150164ae37a77a978d6729c09a5178cbf1aa/rules/S6826/java/asciidocs-links.adoc?plain=1).

=== What is the potential impact?

:random_variable: 42

include::asciidocs.adoc[]

== How to fix it in Spring

=== Code examples

==== Noncompliant code example

[source,text,diff-id=1,diff-type=noncompliant]
----
FIXME
----

==== Compliant solution

[source,text,diff-id=1,diff-type=compliant]
----
FIXED
----

=== How does this work?

:random_variable: 1337

include::asciidocs.adoc[]

== Resources

=== Documentation

* None

2 changes: 2 additions & 0 deletions rules/S6826/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}

0 comments on commit 2730041

Please sign in to comment.