Skip to content

Commit

Permalink
Merge pull request #17 from ThePalaceProject/refactoring
Browse files Browse the repository at this point in the history
Refactoring ios
  • Loading branch information
AEkaterina authored Oct 24, 2023
2 parents b6c87e3 + 6eabbd7 commit df38557
Show file tree
Hide file tree
Showing 68 changed files with 359 additions and 408 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# This workflow helps you trigger a SonarQube analysis of your code and populates
# GitHub Code Scanning alerts with the vulnerabilities found.
# (this feature is available starting from SonarQube 9.7, Developer Edition and above)

# 1. Make sure you add a valid GitHub configuration to your SonarQube (Administration > DevOps platforms > GitHub)

# 2. Import your project on SonarQube
# * Add your repository as a new project by clicking "Create project" from your homepage.
#
# 3. Select GitHub Actions as your CI and follow the tutorial
# * a. Generate a new token and add it to your GitHub repository's secrets using the name SONAR_TOKEN
# (On SonarQube, click on your avatar on top-right > My account > Security or ask your administrator)
#
# * b. Copy/paste your SonarQube host URL to your GitHub repository's secrets using the name SONAR_HOST_URL
#
# * c. Copy/paste the project Key into the args parameter below
# (You'll find this information in SonarQube by following the tutorial or by clicking on Project Information at the top-right of your project's homepage)

# Feel free to take a look at our documentation (https://docs.sonarqube.org/latest/analysis/github-integration/)
# or reach out to our community forum if you need some help (https://community.sonarsource.com/c/sq/10)

name: SonarQube analysis

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

permissions:
pull-requests: read # allows SonarQube to decorate PRs with analysis results

jobs:
Analysis:
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v3
env:
EXCLUDE_PATH: palace/.git
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Install SonarQube Scanner
run: |
curl -L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip -o sonar-scanner.zip
unzip sonar-scanner.zip
rm sonar-scanner.zip
mv sonar-scanner-* sonar-scanner
sudo mv sonar-scanner /opt/
sudo ln -s /opt/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner
- name: Run SonarQube analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: sonar-scanner -Dsonar.projectKey=Mobile_tests -Dsonar.projectName='MobileTests' -Dsonar.sources='src' -Dsonar.language='java' -Dsonar.java.binaries='src' -Dsonar.java.test.binaries='src'
2 changes: 2 additions & 0 deletions src/test/java/constants/RegEx.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public class RegEx {
public static final String PAGE_NUMBER_REGEX_FOR_ANDROID = "Page (\\d+) of (\\d+)";
public static final String VALID_PUBLISHER_OR_CATEGORY_NAME = "([a-zA-Z0-9&\\s-,;'./]*)([a-zA-Z,&\\s;:'.]*)([a-zA-Z0-9,\\s-'.]*)";
public static final String DATE_TIME_FORMAT = "y-M-dd HH:m:s";

private RegEx() { }
}
5 changes: 2 additions & 3 deletions src/test/java/constants/appattributes/AndroidAttributes.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package constants.appattributes;

import lombok.experimental.UtilityClass;

@UtilityClass
public class AndroidAttributes {
public static final String CONTENT_DESC = "content-desc";
public static final String TEXT = "text";
public static final String SELECTED = "selected";
public static final String CHECKED = "checked";

private AndroidAttributes() { }
}
5 changes: 2 additions & 3 deletions src/test/java/constants/appattributes/IosAttributes.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package constants.appattributes;

import lombok.experimental.UtilityClass;

@UtilityClass
public class IosAttributes {
public static final String NAME = "name";
public static final String VALUE = "value";
public static final String VISIBLE = "visible";

private IosAttributes() {}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package constants.keysForContext;
package constants.keysforcontext;

public class ScenarioContextKey {
public static final String SCENARIO_KEY = "SCENARIO";
public static final String LIST_OF_CREDENTIALS_KEY = "CREDENTIALS";

private ScenarioContextKey() { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
public class BookActionButtonNames {
public static final String GET_BUTTON_NAME = "Get";
public static final String DOWNLOAD_BUTTON_NAME = "Download";

private BookActionButtonNames() { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class AbstractILocalizationProvider implements ILocalizationProv
*/
private final String filename;

public AbstractILocalizationProvider(@NonNull String filename) {
protected AbstractILocalizationProvider(@NonNull String filename) {
localizationController = new LocalizationController(StandardCharsets.UTF_8);
this.filename = filename;
bundles.put(DEFAULT_LOCALE, ResourceBundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package constants.localization.providers;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand All @@ -18,6 +19,7 @@ public LocalizationController(Charset charset) {
this.charset = charset;
}

@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format,
ClassLoader loader, boolean reload) throws IOException {
String bundleName = toBundleName(baseName, locale);
Expand All @@ -37,8 +39,9 @@ public ResourceBundle newBundle(String baseName, Locale locale, String format,
stream = loader.getResourceAsStream(resourceName);
}
if (stream != null) {
try {
bundle = new PropertyResourceBundle(new InputStreamReader(stream, charset));
try(InputStreamReader inputStreamReader = new InputStreamReader(stream, charset);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
bundle = new PropertyResourceBundle(bufferedReader);
} finally {
stream.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
public class LocalizationProviderFactory {
private static Map<String, AbstractILocalizationProvider> providers = new ConcurrentHashMap<>();

private LocalizationProviderFactory () { }

public static AbstractILocalizationProvider getProvider(String fileName) {
return providers.computeIfAbsent(fileName, v -> new AbstractILocalizationProvider(v) {
// default
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/constants/util/UtilConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public class UtilConstants {
public static final String PALACE_MARKETPLACE = "palace marketplace";
public static final String PALACE_MARKETPLACE_CATEGORY = "Palace Marketplace Test";
public static final String PALACE_BOOKSHELF = "Palace Bookshelf";

private UtilConstants() { }
}
4 changes: 2 additions & 2 deletions src/test/java/enums/BookType.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public enum BookType {
AUDIOBOOK("audiobook"),
PDF("pdf");

private String bookType;
private String currentBookType;

public String getBookType() {
return bookType;
return currentBookType;
}
}
Loading

0 comments on commit df38557

Please sign in to comment.