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

Manual and sonarcloud review #6

Merged
merged 6 commits into from
May 19, 2024
Merged
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
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: SonarCloud
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BME-MIT-IET_iet-hf-2024-nomad-szabotorok
18 changes: 17 additions & 1 deletion .gitignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mehetett volna bele az *.idea is.

Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
*.class
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"vscjava.vscode-java-pack",
"SonarSource.sonarlint-vscode"
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sonarlint.connectedMode.project": {
"connectionId": "bme-mit-iet-org",
"projectKey": "BME-MIT-IET_iet-hf-2024-nomad-szabotorok"
},
"java.configuration.updateBuildConfiguration": "interactive"
}
75 changes: 75 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>hu.bme.mit.iet.pipe_game</groupId>
<artifactId>pipe_game</artifactId>
<version>1.0-SNAPSHOT</version>

<name>pipe_game</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<sonar.organization>bme-mit-iet-org</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
36 changes: 19 additions & 17 deletions src/Cistern.java → ...ava/hu/bme/mit/iet/pipe_game/Cistern.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package hu.bme.mit.iet.pipe_game;

//
//
// Generated by StarUML(tm) Java Add-In
Expand All @@ -24,6 +26,7 @@ public class Cistern extends SystemPart {
private boolean hasPipe = false;
private int pCount = 0;
private int timeLeft = 2;
private Random rand = new Random();

/**
* Konstruktor, ami beállítja az id-t az osztály nevére és egy eltérő számra
Expand All @@ -37,13 +40,13 @@ public Cistern() {
* A csőnek mindkét szomszégjának magát állítja be,
* hogy ne legyen szabad és ne folyon ki belőle a víz
*/
public void CreatePipe() {
public void createPipe() {
Pipe p = new Pipe();
Control.AddPipe(p);
p.AddNeighbour(this);
p.AddNeighbour(this);
AddNeighbour(p);
AddNeighbour(p);
Control.addPipe(p);
p.addNeighbour(this);
p.addNeighbour(this);
addNeighbour(p);
addNeighbour(p);
pipe = p;
hasPipe = true;
pCount++;
Expand All @@ -52,17 +55,17 @@ public void CreatePipe() {
/**
* Létrehoz egy új pumpát és eltárolja azt a tagváltozójába
*/
public void CreatePump() {
public void createPump() {
pump = new Pump();
Control.AddPump(pump);
Control.addPump(pump);
}

/**
* A tagváltozóban eltárolt pumpa felvétele
* @return visszadjuk a pumpát
*/
@Override
public Pump CarryPump() {
public Pump carryPump() {

Pump p = pump;
pump = null;
Expand All @@ -76,12 +79,12 @@ public Pump CarryPump() {
* @return visszadja hogy mennyi vizet gyűjtött össze
*/
@Override
public int PullWater() {
public int pullWater() {

int points = 0;
for (SystemPart pipe: neighbours) {
points += pipe.getWater();
pipe.setWater(0);
for (SystemPart _pipe: neighbours) {
points += _pipe.getWater();
_pipe.setWater(0);
}
return points;
}
Expand All @@ -90,16 +93,15 @@ public int PullWater() {
* A control minden körben meghívja,
* ha letelik az idő akkor generál egy pumpát vagy csövet
*/
public void Generate() {
Random rand = new Random();
public void generate() {
int coin = rand.nextInt(2);

if (--timeLeft == 0) {
if (coin == 1 ) {
CreatePump();
createPump();
}
else {
CreatePipe();
createPipe();
}
timeLeft = 2;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package hu.bme.mit.iet.pipe_game;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
Expand Down Expand Up @@ -29,7 +31,7 @@ public CisternView(View view, Cistern cistern) {
* frissíti a part JButtont a jelenlegi állapotoknak megfelelően
*/
@Override
public void Update() {
public void update() {
button.setBounds(x,y,50,50);
button.setBackground(Color.RED);

Expand All @@ -40,7 +42,7 @@ public void Update() {
*/
view.getPanel().remove(button);

while (players.size() > 0){
while (!players.isEmpty()){
view.getPanel().remove(players.get(0));
players.remove(0);
}
Expand Down Expand Up @@ -77,6 +79,7 @@ public void Update() {
* getter fügvény ID-re
* @return ID-t adja vissza
*/
@Override
public String getID(){
return cistern.getId();
}
Expand Down
Loading
Loading