Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Some are applicable for different technologies.
| EC86 | GC.Collect should not be called | In most cases, the cost of calling GC.Collect far outweighs the benefits | | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 |
| EC87 | Use collection indexer | Collection indexers should be used instead of Linq, when available | | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 |
| EC88 | Dispose resource asynchronously | Resources that implement `IAsyncDisposable` should be disposed asynchronously | | 🚫 | 🚫 | 🚫 | 🚫 | 🚫 | ✅ | 🚫 |
| EC203 | Detect unoptimized file formats | When it is possible, to use svg format image over other image format | | 🚀 | 🚀 | 🚀 | ✅ | 🚀 | 🚀 | 🚫 |
| EC203 | Detect unoptimized file formats | When it is possible, to use svg format image over other image format | | | 🚀 | 🚀 | ✅ | 🚀 | 🚀 | 🚫 |
| EC404 | Avoid list comprehension in iterations | Use generator comprehension instead of list comprehension in for loop declaration | | 🚫 | 🚫 | 🚫 | ✅ | 🚫 | 🚫 | 🚫 |
| | Use official social media sharing buttons | These JavaScript plugins are very resource-intensive: to work, they require a large number of requests and download heavy files. It is better to prefer direct links. | [cnumr best practices (3rd edition) BP_019](https://github.com/cnumr/best-practices/blob/main/chapters/BP_019_fr.md) | 🚫 | 🚫 | 🚀 | 🚫 | 🚫 | 🚫 | 🚀 |
| | Non-grouped similar CSS declarations | When multiple Document Object Model (DOM) elements have common CSS properties, declare them together in the same style sheet. This method reduces the weight of CSS. | [cnumr best practices (3rd edition) BP_025](https://github.com/cnumr/best-practices/blob/main/chapters/BP_025_fr.md) | 🚫 | 🚫 | 🚧 | 🚫 | 🚫 | 🚫 | 🚫 |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
If possible, the utilisation of svg image format (or `<svg/>` html tag) is recommended over other image format.

Because SVGs are generally smaller than other image format, they’re less taxing on your server despite needing to render on load.

When to use SVG :

- Your image is used for decorative website graphics, logos, icons, graphs and diagrams, and other simple images.
- You image require animation.
- You image need to be responsive and scale without lack of quality.

Some advantages of using SVG:

- SVGs are scalable and will render pixel-perfect at any resolution whereas JPEGs, PNGs and GIFs will not.
- SVGs are vector images and therefore are usually much smaller in file-size than bitmap-based images.
- SVGs can be embedded into the HTML which means they can be cached, edited directly using CSS and indexed for greater accessibility.
- SVGs can be animated directly or by using CSS or JavaScript making it easy for web designers to add interactivity to a site.

## Noncompliant Code Example

```
img_jpg = "image.jpg"
```

## Compliant Solution

```
img_svg = "image.svg"
```

## Noncompliant Code Example

```
public void foo() {
// ...
image_format = testImage("image.jpg")
// ...
}
```

## Compliant Solution

```
public void foo() {
// ...
image_format = testImage("image.svg")
// ...
}
```

## Noncompliant Code Example

```
public void foo() {
// ...
return '<html><img src="xx/xx/image.bmp"></html>'
// ...
}
```

## Compliant Solution

```
public void foo() {
// ...
return '<html><img src="xx/xx/image.svg"></html>'
// ...
}
```

Or

```
public void foo() {
// ...
return ('<html><svg width="100" height="100"><circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow"/></svg></html>')
// ...
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -30,49 +30,48 @@ img_svg = "image.svg"
## Noncompliant Code Example

```
public void foo() {
// ...
def foo() :
# ...
image_format = testImage("image.jpg")
// ...
}
# ...
```

## Compliant Solution

```
public void foo() {
// ...
def foo() :
# ...
image_format = testImage("image.svg")
// ...
# ...
}
```

## Noncompliant Code Example

```
public void foo() {
// ...
def foo() :
# ...
return '<html><img src="xx/xx/image.bmp"></html>'
// ...
# ...
}
```

## Compliant Solution

```
public void foo() {
// ...
def foo() :
# ...
return '<html><img src="xx/xx/image.svg"></html>'
// ...
# ...
}
```

Or

```
public void foo() {
// ...
def foo() :
# ...
return ('<html><svg width="100" height="100"><circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow"/></svg></html>')
// ...
# ...
}
```