Skip to content

Commit

Permalink
Merge pull request #528 from bci-oss/25-check-codestyle
Browse files Browse the repository at this point in the history
Add code style configuration and automatic check
  • Loading branch information
atextor authored Feb 16, 2024
2 parents dfb1ca2 + cda38c0 commit 4d2c721
Show file tree
Hide file tree
Showing 347 changed files with 4,858 additions and 2,656 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/pull-request-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check code style
if: matrix.os == 'linux-latest'
uses: dbelyaev/action-checkstyle@e89baf0f8b488b946345b7de8e975be1e3606387 # v1.5.6
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
checkstyle_config: esmf-checkstyle.xml
level: error
fail_on_error: true

- name: Setup JDK
uses: graalvm/setup-graalvm@b8dc5fccfbc65b21dd26e8341e7b21c86547f61b # v1
with:
Expand Down
12 changes: 11 additions & 1 deletion CONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ write code for the ESMF SDK.
## General Conventions
Our code conventions are based on the [Google Java Style
Guide](https://google.github.io/styleguide/javaguide.html) but detailed and adjusted for the needs
of the ESMF SDK.
of the ESMF SDK. The code style is described using [Checkstyle](https://checkstyle.sourceforge.io/)
and can be found in the file esmf-checkstyle.xml. You can use this file to configure Checkstyle
using a suitable plugin in your favorite IDE, or to run Checkstyle via the command line, e.g., from
the root directory of the esmf-sdk, run:
`java -jar /path/to/checkstyle-10.13.0-all.jar com.puppycrawl.tools.checkstyle.Main -c esmf-checkstyle.xml .`
Furthermore, the files esmf-intellij-codestyle.xml and esmf-intellij-inspections.xml are provided
that can be
[imported](https://www.jetbrains.com/help/idea/configuring-code-style.html#import-export-schemes) in
the Java code style settings and
[imported](https://www.jetbrains.com/help/idea/inspections-settings.html#profile_management) in the
Inspections, respectively, in the IntelliJ IDEA IDE.

## Copyright header
See [CONTRIBUTING](CONTRIBUTING.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public UnsupportedVersionException() {
}

public UnsupportedVersionException( final VersionNumber versionNumber ) {
super( "Meta model version " + versionNumber + " is not supported");
super( "Meta model version " + versionNumber + " is not supported" );
}

public UnsupportedVersionException( final String versionNumber ) {
super( "Meta model version " + versionNumber + " is not supported");
super( "Meta model version " + versionNumber + " is not supported" );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
import java.util.Set;
import java.util.stream.Stream;

import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Statement;

import org.eclipse.esmf.samm.KnownVersion;
import org.eclipse.esmf.aspectmodel.MissingMetaModelVersionException;
import org.eclipse.esmf.aspectmodel.MultipleMetaModelVersionsException;
import org.eclipse.esmf.aspectmodel.UnsupportedVersionException;
import org.eclipse.esmf.aspectmodel.VersionNumber;
import org.eclipse.esmf.aspectmodel.resolver.services.VersionedModel;
import org.eclipse.esmf.samm.KnownVersion;

import io.vavr.control.Try;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.Statement;

/**
* Provides functionality to resolve Aspect Meta Model resources which reside in the classpath.
Expand All @@ -50,9 +50,9 @@ default Try<VersionedModel> mergeMetaModelIntoRawModel( final Model rawModel, fi
* Retrieves the meta model version an Aspect model uses
*
* @param model The RDF model containing an Aspect Model
* @return A {@link Try.Success} with the used meta model version, or a {@link Try.Failure} with
* one of {@link MissingMetaModelVersionException}, {@link MultipleMetaModelVersionsException}
* or {@link UnsupportedVersionException} (if the version can not be parsed).
* @return A {@link Try.Success} with the used meta model version, or a {@link Try.Failure} with one of
* {@link MissingMetaModelVersionException}, {@link MultipleMetaModelVersionsException} or {@link UnsupportedVersionException} (if the
* version can not be parsed).
*/
default Try<VersionNumber> getMetaModelVersion( final Model model ) {
final Set<VersionNumber> metaModelVersionsUsedInModel = getUsedMetaModelVersions( model );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

package org.eclipse.esmf.aspectmodel.resolver.services;

import org.apache.jena.rdf.model.Model;

import org.eclipse.esmf.samm.KnownVersion;
import org.eclipse.esmf.aspectmodel.VersionNumber;
import org.eclipse.esmf.samm.KnownVersion;

import org.apache.jena.rdf.model.Model;

/**
* Encapsulates an Aspect Model (as RDF model) and the Meta Model version it uses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import java.util.List;

import org.eclipse.esmf.aspectmodel.resolver.AspectMetaModelResourceResolver;
import org.eclipse.esmf.aspectmodel.VersionNumber;
import org.eclipse.esmf.aspectmodel.resolver.AspectMetaModelResourceResolver;
import org.eclipse.esmf.aspectmodel.versionupdate.migrator.Migrator;

public interface MigratorFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

import java.util.Optional;

import org.apache.jena.rdf.model.Model;

import org.eclipse.esmf.aspectmodel.VersionNumber;

import org.apache.jena.rdf.model.Model;

public interface Migrator {

int order();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

package org.eclipse.esmf.aspectmodel;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.eclipse.esmf.metamodel.Type;
import org.eclipse.esmf.metamodel.Value;

@SuppressWarnings( { "squid:S1150", "This is not java.util.Enumeration." } )
/**
* A list of possible states. Provides a default value.
*
Expand All @@ -25,8 +24,8 @@
public interface State extends Enumeration {

/**
* @return the default value defined for this State. The type of the values is determined by the {@link Type}
* returned by {@link State#getDataType()}.
* @return the default value defined for this State. The type of the values is determined by the {@link Type} returned by
* {@link State#getDataType()}.
*/
Value getDefaultValue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.util.Optional;
import java.util.StringJoiner;

import org.eclipse.esmf.metamodel.Characteristic;
import org.eclipse.esmf.characteristic.Collection;
import org.eclipse.esmf.metamodel.Characteristic;
import org.eclipse.esmf.metamodel.CollectionValue;
import org.eclipse.esmf.metamodel.Type;
import org.eclipse.esmf.metamodel.impl.DefaultCharacteristic;
Expand Down Expand Up @@ -109,9 +109,9 @@ public boolean equals( final Object o ) {
return false;
}
final DefaultCollection that = (DefaultCollection) o;
return allowDuplicates == that.allowDuplicates &&
ordered == that.ordered &&
Objects.equals( elementCharacteristic, that.elementCharacteristic );
return allowDuplicates == that.allowDuplicates
&& ordered == that.ordered
&& Objects.equals( elementCharacteristic, that.elementCharacteristic );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.Duration;

import org.eclipse.esmf.metamodel.Type;
import org.eclipse.esmf.metamodel.Unit;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.Either;

import org.eclipse.esmf.metamodel.Characteristic;
import org.eclipse.esmf.metamodel.Type;
import org.eclipse.esmf.metamodel.impl.DefaultCharacteristic;
Expand Down Expand Up @@ -89,8 +88,8 @@ public boolean equals( final Object o ) {
return false;
}
final DefaultEither that = (DefaultEither) o;
return Objects.equals( left, that.left ) &&
Objects.equals( right, that.right );
return Objects.equals( left, that.left )
&& Objects.equals( right, that.right );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.Enumeration;

import org.eclipse.esmf.metamodel.Type;
import org.eclipse.esmf.metamodel.Value;
import org.eclipse.esmf.metamodel.impl.DefaultCharacteristic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.List;

import org.eclipse.esmf.metamodel.Characteristic;
import org.eclipse.esmf.metamodel.CollectionValue;
import org.eclipse.esmf.metamodel.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.Quantifiable;

import org.eclipse.esmf.metamodel.Type;
import org.eclipse.esmf.metamodel.Unit;
import org.eclipse.esmf.metamodel.impl.DefaultCharacteristic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.Set;

import org.eclipse.esmf.metamodel.Characteristic;
import org.eclipse.esmf.metamodel.CollectionValue;
import org.eclipse.esmf.metamodel.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.SortedSet;

import org.eclipse.esmf.metamodel.Characteristic;
import org.eclipse.esmf.metamodel.CollectionValue;
import org.eclipse.esmf.metamodel.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.State;

import org.eclipse.esmf.metamodel.Type;
import org.eclipse.esmf.metamodel.Value;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
Expand All @@ -26,7 +25,8 @@
public class DefaultState extends DefaultEnumeration implements State {
private final Value defaultValue;

public DefaultState( final MetaModelBaseAttributes metaModelBaseAttributes, final Type dataType, final List<Value> values, final Value defaultValue ) {
public DefaultState( final MetaModelBaseAttributes metaModelBaseAttributes, final Type dataType, final List<Value> values,
final Value defaultValue ) {
super( metaModelBaseAttributes, dataType, values );
this.defaultValue = defaultValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public boolean equals( final Object o ) {
return false;
}
final DefaultStructuredValue that = (DefaultStructuredValue) o;
return Objects.equals( deconstructionRule, that.deconstructionRule ) &&
Objects.equals( elements, that.elements );
return Objects.equals( deconstructionRule, that.deconstructionRule )
&& Objects.equals( elements, that.elements );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.TimeSeries;

import org.eclipse.esmf.metamodel.Characteristic;
import org.eclipse.esmf.metamodel.Type;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import java.util.Optional;
import java.util.StringJoiner;

import org.eclipse.esmf.characteristic.Trait;
import org.eclipse.esmf.metamodel.Characteristic;
import org.eclipse.esmf.metamodel.Constraint;
import org.eclipse.esmf.characteristic.Trait;
import org.eclipse.esmf.metamodel.Type;
import org.eclipse.esmf.metamodel.impl.DefaultCharacteristic;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.constraint.EncodingConstraint;

import org.eclipse.esmf.metamodel.impl.DefaultConstraint;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
import org.eclipse.esmf.metamodel.visitor.AspectVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.constraint.FixedPointConstraint;

import org.eclipse.esmf.metamodel.impl.DefaultConstraint;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
import org.eclipse.esmf.metamodel.visitor.AspectVisitor;
Expand Down Expand Up @@ -76,8 +75,8 @@ public boolean equals( final Object o ) {
return false;
}
final DefaultFixedPointConstraint that = (DefaultFixedPointConstraint) o;
return Objects.equals( scale, that.scale ) &&
Objects.equals( integer, that.integer );
return Objects.equals( scale, that.scale )
&& Objects.equals( integer, that.integer );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.constraint.LanguageConstraint;

import org.eclipse.esmf.metamodel.impl.DefaultConstraint;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
import org.eclipse.esmf.metamodel.visitor.AspectVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.constraint.LengthConstraint;

import org.eclipse.esmf.metamodel.impl.DefaultConstraint;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
import org.eclipse.esmf.metamodel.visitor.AspectVisitor;
Expand Down Expand Up @@ -87,8 +86,8 @@ public boolean equals( final Object o ) {
return false;
}
final DefaultLengthConstraint that = (DefaultLengthConstraint) o;
return Objects.equals( minValue, that.minValue ) &&
Objects.equals( maxValue, that.maxValue );
return Objects.equals( minValue, that.minValue )
&& Objects.equals( maxValue, that.maxValue );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.constraint.LocaleConstraint;

import org.eclipse.esmf.metamodel.impl.DefaultConstraint;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
import org.eclipse.esmf.metamodel.visitor.AspectVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.constraint.RangeConstraint;

import org.eclipse.esmf.metamodel.ScalarValue;
import org.eclipse.esmf.metamodel.impl.BoundDefinition;
import org.eclipse.esmf.metamodel.impl.DefaultConstraint;
Expand Down Expand Up @@ -106,10 +105,10 @@ public boolean equals( final Object o ) {
return false;
}
final DefaultRangeConstraint that = (DefaultRangeConstraint) o;
return Objects.equals( minValue, that.minValue ) &&
Objects.equals( maxValue, that.maxValue ) &&
lowerBoundDefinition == that.lowerBoundDefinition &&
upperBoundDefinition == that.upperBoundDefinition;
return Objects.equals( minValue, that.minValue )
&& Objects.equals( maxValue, that.maxValue )
&& lowerBoundDefinition == that.lowerBoundDefinition
&& upperBoundDefinition == that.upperBoundDefinition;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.StringJoiner;

import org.eclipse.esmf.constraint.RegularExpressionConstraint;

import org.eclipse.esmf.metamodel.impl.DefaultConstraint;
import org.eclipse.esmf.metamodel.loader.MetaModelBaseAttributes;
import org.eclipse.esmf.metamodel.visitor.AspectVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface ComplexType extends Type, StructureElement {
default List<ComplexType> getExtendingElements() {
return Collections.emptyList();
}

default boolean isAbstractEntity() {
return false;
}
Expand All @@ -41,7 +41,8 @@ default boolean isAbstractEntity() {
*/
default List<Property> getAllProperties() {
if ( getExtends().isPresent() ) {
return Stream.of( getProperties(), getExtends().get().getAllProperties() ).flatMap( Collection::stream ).collect( Collectors.toList() );
return Stream.of( getProperties(), getExtends().get().getAllProperties() ).flatMap( Collection::stream )
.collect( Collectors.toList() );
}
return List.copyOf( getProperties() );
}
Expand Down
Loading

0 comments on commit 4d2c721

Please sign in to comment.