Skip to content

Commit

Permalink
Fix code for codacy style (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
simoexpo authored Mar 5, 2020
1 parent af105b5 commit c4d5f4b
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 72 deletions.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
- OS: \[e.g. iOS]
- Browser \[e.g. chrome, safari]
- Version \[e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
- Device: \[e.g. iPhone6]
- OS: \[e.g. iOS8.1]
- Browser \[e.g. stock browser, safari]
- Version \[e.g. 22]

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I'm always frustrated when \[...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Expand Down
17 changes: 7 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ Examples of behavior that contributes to a positive environment for our communit

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Expand Down Expand Up @@ -74,11 +71,11 @@ Community leaders will follow these Community Impact Guidelines in determining t
## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
available at <https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.

[homepage]: https://www.contributor-covenant.org
2 changes: 1 addition & 1 deletion dev/start_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docker_cmd_status=$?
if [[ $docker_cmd_status == 0 ]]; then
# the command has succeeded
echo -e "\nContainers had been successfully started. " \
'Use `docker-compose logs -f <service-name>` to check the logs.' >&2
"Use 'docker-compose logs -f <service-name>' to check the logs." >&2
fi

exit $docker_cmd_status
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final case class AviationConfig(
airlineStream: ApiProviderStreamConfig,
cityStream: ApiProviderStreamConfig
) {
def getAviationUri(path: String): String = {
def aviationUri(path: String): String = {
val query = Uri.Query("key" -> key)
Uri(host.resolve(path).toString)
.withQuery(query)
Expand All @@ -39,7 +39,7 @@ final case class OpenSkyConfig(
tickSource: TickSourceConfig,
flightStateStream: ApiProviderStreamConfig
) {
def getOpenSkyUri(path: String): String =
def openSkyUri(path: String): String =
host.resolve(path).toString
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package it.bitrock.dvs.producer.aviationedge.kafka

import it.bitrock.dvs.model.avro._
import it.bitrock.dvs.model.avro.monitoring.FlightRequestComputationStatus
import it.bitrock.dvs.model.avro.{AirlineRaw, AirplaneRaw, AirportRaw, CityRaw, FlightRaw, FlightStateRaw, ParserError}

object KafkaTypes {
type Key = String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@ package it.bitrock.dvs.producer.aviationedge.kafka

import KafkaTypes._
import it.bitrock.dvs.producer.aviationedge.kafka.models.RawImplicitConversions._
import it.bitrock.dvs.producer.aviationedge.model.{
AirlineMessageJson,
AirplaneMessageJson,
AirportMessageJson,
CityMessageJson,
ErrorMessageJson,
FlightMessageJson,
FlightStateJson,
MessageJson,
MonitoringMessageJson
}
import it.bitrock.dvs.producer.aviationedge.model._

trait ToValuePair[J, K, V] {
def toValuePair(j: J): (K, V)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ object RawImplicitConversions {
def toFlightStateRaw: FlightStateRaw =
FlightStateRaw(
flightStateJson.callsign,
Instant.ofEpochSecond(flightStateJson.time_position),
Instant.ofEpochSecond(flightStateJson.timePosition),
Geography(
flightStateJson.latitude,
flightStateJson.longitude,
flightStateJson.geo_altitude,
flightStateJson.true_track
flightStateJson.geoAltitude,
flightStateJson.trueTrack
),
msToKmh(flightStateJson.velocity)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ final case class FlightStatesJson(time: Long, states: List[List[JsValue]])

final case class FlightStateJson(
callsign: String,
time_position: Long,
timePosition: Long,
longitude: Double,
latitude: Double,
velocity: Double,
true_track: Double,
geo_altitude: Double
trueTrack: Double,
geoAltitude: Double
) extends MessageJson
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ApiProviderFlow()(implicit system: ActorSystem, ec: ExecutionContext) exte
.to[List[Either[ErrorMessageJson, MessageJson]]]
.map(list => addPathToLeft(list, path))
.recover {
case ex =>
case NonFatal(ex) =>
List(Left(ErrorMessageJson(path, ex.getMessage, apiResponseBody, Instant.now)))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package it.bitrock.dvs.producer.aviationedge.services
import java.time.Instant

import akka.NotUsed
import akka.stream.scaladsl.{Broadcast, Flow, GraphDSL, Keep, Partition, RunnableGraph, Sink, Source}
import akka.stream.scaladsl._
import akka.stream.{ClosedShape, FlowShape}
import it.bitrock.dvs.producer.aviationedge.model.PartitionPorts._
import it.bitrock.dvs.producer.aviationedge.model._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ object JsonSupport extends SprayJsonSupport with DefaultJsonProtocol {
Try(
FlightStateJson(
callsign = state(1).convertTo[String].trim.toUpperCase,
time_position = state(3).convertTo[Long],
timePosition = state(3).convertTo[Long],
longitude = state(5).convertTo[Double],
latitude = state(6).convertTo[Double],
velocity = state(9).convertTo[Double],
true_track = state(10).convertTo[Double],
geo_altitude = state(13).convertTo[Double]
trueTrack = state(10).convertTo[Double],
geoAltitude = state(13).convertTo[Double]
)
).toEither.left.map(ex => ErrorMessageJson("", ex.getMessage, json.compactPrint, Instant.now))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object MainFunctions {

val tickSource = new TickSource(config.pollingStart, config.pollingInterval, aviationConfig.tickSource).source
val aviationFlow =
new ApiProviderFlow().flow(aviationConfig.getAviationUri(config.path), aviationConfig.apiTimeout)(
new ApiProviderFlow().flow(aviationConfig.aviationUri(config.path), aviationConfig.apiTimeout)(
aviationEdgePayloadJsonReader
)
val rawSink = AviationStreamContext[A].sink(kafkaConfig)
Expand All @@ -64,7 +64,7 @@ object MainFunctions {
val config = OpenSkyStreamContext[A].config(apiProviderConfig)

val tickSource = new TickSource(config.pollingStart, config.pollingInterval, openSkyConfig.tickSource).source
val openSkyFlow = new ApiProviderFlow().flow(openSkyConfig.getOpenSkyUri(config.path), openSkyConfig.apiTimeout)(
val openSkyFlow = new ApiProviderFlow().flow(openSkyConfig.openSkyUri(config.path), openSkyConfig.apiTimeout)(
openSkyResponsePayloadJsonFormat
)
val rawSink = AviationStreamContext[A].sink(kafkaConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import it.bitrock.dvs.model.avro._
import it.bitrock.dvs.model.avro.monitoring.FlightRequestComputationStatus
import it.bitrock.dvs.producer.aviationedge.model._

trait TestValues {
object TestValues {
final val IcaoNumber = "SWR6U"
final val Timestamp = Instant.now()
final val Content = "a content"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package it.bitrock.dvs.producer.aviationedge.kafka

import KafkaErrorSinkFactorySpec._
import akka.actor.ActorSystem
import akka.kafka.ProducerSettings
import akka.stream.scaladsl.Source
import akka.testkit.TestKit
import io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig
import it.bitrock.dvs.producer.aviationedge.TestValues
import it.bitrock.dvs.producer.aviationedge.TestValues._
import it.bitrock.dvs.producer.aviationedge.kafka.KafkaTypes.{Error, Key}
import it.bitrock.dvs.producer.aviationedge.model.ErrorMessageJson
import it.bitrock.kafkacommons.serialization.ImplicitConversions._
Expand All @@ -20,9 +21,7 @@ class KafkaErrorSinkFactorySpec
with Suite
with AnyWordSpecLike
with BeforeAndAfterAll
with EmbeddedKafka
with TestValues {
import KafkaErrorSinkFactorySpec._
with EmbeddedKafka {

"sink method" should {
"convert a domain model to Kafka model and push it to a topic" in ResourceLoaner.withFixture {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package it.bitrock.dvs.producer.aviationedge.kafka

import KafkaFlightSinkFactorySpec._
import akka.actor.ActorSystem
import akka.kafka.ProducerSettings
import akka.stream.scaladsl.Source
import akka.testkit.TestKit
import io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig
import it.bitrock.dvs.producer.aviationedge.TestValues
import it.bitrock.dvs.producer.aviationedge.TestValues._
import it.bitrock.dvs.producer.aviationedge.kafka.KafkaTypes.{Flight, Key}
import it.bitrock.dvs.producer.aviationedge.model.MessageJson
import it.bitrock.kafkacommons.serialization.ImplicitConversions._
Expand All @@ -20,9 +21,7 @@ class KafkaFlightSinkFactorySpec
with Suite
with AnyWordSpecLike
with BeforeAndAfterAll
with EmbeddedKafka
with TestValues {
import KafkaFlightSinkFactorySpec._
with EmbeddedKafka {

"sink method" should {
"convert a domain model to Kafka model and push it to a topic" in ResourceLoaner.withFixture {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package it.bitrock.dvs.producer.aviationedge.kafka

import KafkaFlightStateSinkFactorySpec._
import akka.actor.ActorSystem
import akka.kafka.ProducerSettings
import akka.stream.scaladsl.Source
import akka.testkit.TestKit
import io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig
import it.bitrock.dvs.producer.aviationedge.TestValues
import it.bitrock.dvs.producer.aviationedge.TestValues._
import it.bitrock.dvs.producer.aviationedge.kafka.KafkaTypes.{FlightState, Key}
import it.bitrock.dvs.producer.aviationedge.model.MessageJson
import it.bitrock.kafkacommons.serialization.ImplicitConversions._
Expand All @@ -20,9 +21,7 @@ class KafkaFlightStateSinkFactorySpec
with Suite
with AnyWordSpecLike
with BeforeAndAfterAll
with EmbeddedKafka
with TestValues {
import KafkaFlightStateSinkFactorySpec._
with EmbeddedKafka {

"sink method" should {
"convert a domain model to Kafka model and push it to a topic" in ResourceLoaner.withFixture {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package it.bitrock.dvs.producer.aviationedge.kafka

import KafkaMonitoringSinkFactorySpec._
import akka.actor.ActorSystem
import akka.kafka.ProducerSettings
import akka.stream.scaladsl.Source
import akka.testkit.TestKit
import io.confluent.kafka.serializers.AbstractKafkaAvroSerDeConfig
import it.bitrock.dvs.producer.aviationedge.TestValues
import it.bitrock.dvs.producer.aviationedge.TestValues._
import it.bitrock.dvs.producer.aviationedge.kafka.KafkaTypes.{Key, Monitoring}
import it.bitrock.dvs.producer.aviationedge.model.MonitoringMessageJson
import it.bitrock.kafkacommons.serialization.ImplicitConversions._
Expand All @@ -20,9 +21,7 @@ class KafkaMonitoringSinkFactorySpec
with Suite
with AnyWordSpecLike
with BeforeAndAfterAll
with EmbeddedKafka
with TestValues {
import KafkaMonitoringSinkFactorySpec._
with EmbeddedKafka {

"sink method" should {
"convert a domain model to Kafka model and push it to a topic" in ResourceLoaner.withFixture {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import akka.actor.ActorSystem
import akka.http.scaladsl.model.{HttpEntity, HttpResponse, StatusCodes, Uri}
import akka.stream.scaladsl.{Keep, Sink, Source}
import akka.testkit.TestKit
import it.bitrock.dvs.producer.aviationedge.TestValues
import it.bitrock.dvs.producer.aviationedge.TestValues._
import it.bitrock.dvs.producer.aviationedge.model._
import it.bitrock.dvs.producer.aviationedge.services.JsonSupport._
import it.bitrock.testcommons.Suite
Expand All @@ -19,7 +19,6 @@ class ApiProviderFlowSpec
extends TestKit(ActorSystem("AviationFlowSpec"))
with Suite
with AnyWordSpecLike
with TestValues
with EitherValues
with ScalaFutures
with IntegrationPatience {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package it.bitrock.dvs.producer.aviationedge.services

import it.bitrock.dvs.producer.aviationedge.TestValues
import it.bitrock.dvs.producer.aviationedge.TestValues._
import it.bitrock.dvs.producer.aviationedge.model.MessageJson
import it.bitrock.dvs.producer.aviationedge.model.PartitionPorts._
import it.bitrock.dvs.producer.aviationedge.services.Graphs._
import it.bitrock.testcommons.Suite
import org.scalatest.wordspec.AnyWordSpecLike

class FilterFunctionsSpec extends Suite with AnyWordSpecLike with TestValues {
import Graphs._
class FilterFunctionsSpec extends Suite with AnyWordSpecLike {

"filter function" should {
"exclude airlines with status not equal to active" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import akka.actor.ActorSystem
import akka.stream.scaladsl.{Keep, Sink, Source}
import akka.testkit.TestKit
import com.typesafe.scalalogging.LazyLogging
import it.bitrock.dvs.producer.aviationedge.TestValues
import it.bitrock.dvs.producer.aviationedge.TestValues._
import it.bitrock.dvs.producer.aviationedge.model.{ErrorMessageJson, MessageJson, MonitoringMessageJson}
import it.bitrock.dvs.producer.aviationedge.services.Graphs._
import it.bitrock.testcommons.Suite
import net.manub.embeddedkafka.schemaregistry._
import org.scalatest.concurrent.PatienceConfiguration.Timeout
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.wordspec.AnyWordSpecLike
Expand All @@ -24,8 +23,6 @@ class GraphsSpec
with Suite
with AnyWordSpecLike
with BeforeAndAfterAll
with EmbeddedKafka
with TestValues
with ScalaFutures
with LazyLogging
with OptionValues {
Expand Down

0 comments on commit c4d5f4b

Please sign in to comment.