Skip to content

Commit

Permalink
Merge branch 'main' into rule/EC512-swift
Browse files Browse the repository at this point in the history
  • Loading branch information
dedece35 authored May 13, 2024
2 parents cd77dee + d2d19db commit e775df6
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 106 deletions.
32 changes: 26 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- [#239](https://github.com/green-code-initiative/ecoCode/issues/239) Add new Java rule EC24 : Optimize Database SQL Queries (Clause LIMIT)
- [#298](https://github.com/green-code-initiative/ecoCode/pull/298) Add HTML rule EC36 (Avoid autoplay for videos and audio content)

### Changed

### Deleted

## [1.5.3] - 2024-05-03

### Changed

- [PHP #23](https://github.com/green-code-initiative/ecoCode-php/issues/23) Deprecation of EC22 rule for PHP (waiting for measurement) - correction

## [1.5.2] - 2024-05-02

### Changed

- [PHP #23](https://github.com/green-code-initiative/ecoCode-php/issues/23) Deprecation of EC22 rule for PHP (waiting for measurement)

## [1.5.1] - 2024-04-29

### Added

- Swift rules cleanup and updates (removed duplicated rules, added [EC602])
- [#18](https://github.com/green-code-initiative/ecoCode-csharp/issues/18) [EC81] [C#] Specify struct layout
- [#285](https://github.com/green-code-initiative/ecoCode/pull/285) [EC82] [C#] Cariable can be made constant
Expand All @@ -18,10 +39,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#34](https://github.com/green-code-initiative/ecoCode-csharp/issues/34) [EC85] [C#] Make type sealed
- [#290](https://github.com/green-code-initiative/ecoCode/issues/290) [EC512] Swift port

### Changed

### Deleted

## [1.5.0] - 2024-02-02

### Added
Expand Down Expand Up @@ -271,7 +288,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Comparison List

[unreleased](https://github.com/green-code-initiative/ecoCode/compare/1.5.0...HEAD)
[unreleased](https://github.com/green-code-initiative/ecoCode/compare/1.5.3...HEAD)
[1.5.3](https://github.com/green-code-initiative/ecoCode/compare/1.5.2...1.5.3)
[1.5.2](https://github.com/green-code-initiative/ecoCode/compare/1.5.1...1.5.2)
[1.5.1](https://github.com/green-code-initiative/ecoCode/compare/1.5.0...1.5.1)
[1.5.0](https://github.com/green-code-initiative/ecoCode/compare/1.4.7...1.5.0)
[1.4.7](https://github.com/green-code-initiative/ecoCode/compare/1.4.6...1.4.7)
[1.4.6](https://github.com/green-code-initiative/ecoCode/compare/1.4.5...1.4.6)
Expand Down
117 changes: 60 additions & 57 deletions RULES.md

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion ecocode-rules-specifications/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.ecocode</groupId>
<artifactId>ecocode-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.5.4-SNAPSHOT</version>
</parent>

<artifactId>ecocode-rules-specifications</artifactId>
Expand Down Expand Up @@ -198,6 +198,18 @@
</descriptors>
</configuration>
</execution>
<execution>
<id>assembly-html</id>
<phase>prepare-package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/html.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
Expand Down
18 changes: 18 additions & 0 deletions ecocode-rules-specifications/src/main/assembly/html.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 https://maven.apache.org/xsd/assembly-2.1.1.xsd">
<id>html</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<includes>
<include>io/ecocode/rules/html/*.*</include>
</includes>
<outputDirectory/>
</fileSet>
</fileSets>
</assembly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"status": "deprecated"
}

This file was deleted.

22 changes: 22 additions & 0 deletions ecocode-rules-specifications/src/main/rules/EC36/EC36.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"title": "Avoid autoplay for videos and audio content",
"type": "CODE_SMELL",
"code": {
"impacts": {
"MAINTAINABILITY": "MEDIUM"
},
"attribute": "EFFICIENT"
},
"status": "ready",
"remediation": {
"func": "Constant\/Issue",
"constantCost": "5min"
},
"tags": [
"ecocode",
"eco-design",
"video",
"audio"
],
"defaultSeverity": "Major"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
:!sectids:

== Why is this an issue?

Autoplaying media consumes unnecessary energy, especially when users might not be actively engaging with the content.
This can drain battery life on devices, particularly on mobile devices, leading to increased energy consumption and potentially contributing to environmental impact.
It can also consume data, particularly for users on limited data plans or in areas with poor internet connectivity.
This can lead to unnecessary data usage and potentially increased costs for users.

However, even without autoplay, segments of video or audio files might still download.
This leads to unnecessary data usage, especially if users don't commence playback.
To mitigate this, it's crucial to prevent browsers from preloading any content by configuring the appropriate settings.

Video:

[source,html,data-diff-id="1",data-diff-type="noncompliant"]
----
<video src="videofile.webm" autoplay></video> // Non-compliant
----

[source,html,data-diff-id="1",data-diff-type="compliant"]
----
<video src="videofile.webm" preload="none"></video> // Compliant
----

Audio:

[source,html,data-diff-id="1",data-diff-type="noncompliant"]
----
<audio controls src="audiofile.mp3" autoplay></audio> // Non-compliant
----

[source,html,data-diff-id="1",data-diff-type="compliant"]
----
<audio controls src="audiofile.mp3" preload="none"></audio> // Compliant
----

== Resources

=== Documentation

- https://github.com/cnumr/best-practices/blob/main/chapters/BP_4003_en.md[CNUMR best practices] - Avoid autoplay for videos and audio content

=== Articles & blog posts

- https://eco-conception.designersethiques.org/guide/en/content/5-2-video.html[eco-conception.designersethiques.org - 5.2. Video and sound]
- https://www.ecoindex.fr/en/ecodesign/[www.ecoindex.fr - Some good practices]
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.ecocode</groupId>
<artifactId>ecocode-parent</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.5.4-SNAPSHOT</version>
<packaging>pom</packaging>

<name>ecoCode Sonar Plugins Project</name>
Expand Down

0 comments on commit e775df6

Please sign in to comment.