Skip to content

Commit

Permalink
Merge branch 'release/0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
NoelleDL committed Oct 10, 2022
2 parents d1ca52e + 6dc67b7 commit df0c1b5
Show file tree
Hide file tree
Showing 18 changed files with 202 additions and 98 deletions.
93 changes: 93 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# This file was inspired by the golangci-lint one:
# https://github.com/golangci/golangci-lint/blob/master/.golangci.yml
run:
# default concurrency is a available CPU number
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0
gocyclo:
min-complexity: 20
gocognit:
min-complexity: 100
maligned:
suggest-new: true
dupl:
threshold: 100
goconst:
min-len: 2
min-occurrences: 2
misspell:
locale: UK
lll:
line-length: 140
gofmt:
simplify: false
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- wrapperFunc
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- hugeParam
funlen:
# lines: 100
# statements: 100

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- deadcode
- depguard
- dogsled
- gochecknoinits
- gocritic
- gocyclo
- gofmt
- goimports
- revive
- gosec
- govet
- ineffassign
- nakedret
- unconvert
- varcheck
- whitespace
- gocognit
- prealloc

issues:
exclude-rules:
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- goconst
- revive
- gocritic
- ineffassign
- govet
- typecheck
new: false

# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.43.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ audit:
build: generate-prod
go build -tags 'production' $(LDFLAGS) -o $(BINPATH)/dp-frontend-feedback-controller

lint:
go install github.com/golangci/golangci-lint/cmd/[email protected]
golangci-lint run ./...

.PHONY: debug
debug: generate-debug
go build -tags 'debug' $(LDFLAGS) -o $(BINPATH)/dp-frontend-feedback-controller
Expand Down
4 changes: 4 additions & 0 deletions assets/locales/service.cy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ one = "The whole ONS website or general feedback"
[FeedbackASpecificPage]
description = "A specific page"
one = "A specific page"

[FeedbackThanks]
description = "Thank you"
one = "Diloch"
4 changes: 4 additions & 0 deletions assets/locales/service.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,7 @@ one = "The whole ONS website or general feedback"
[FeedbackASpecificPage]
description = "A specific page"
one = "A specific page"

[FeedbackThanks]
description = "Thank you"
one = "Thank you"
22 changes: 22 additions & 0 deletions assets/templates/feedback-thanks.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{$Language := .Language}}
<div class="feedback-page-intro background--gallery">
<div class="wrapper">
<div class="col-wrap">
<div class="col margin-top--1">
{{ template "partials/breadcrumb" . }}
<h1 class="feedback-thanks feedback-page-intro__title margin-bottom--4" aria-live="polite">
<strong>{{ localise "FeedbackThanks" $Language 1 $.Metadata.Title }}</strong>
</h1>
</div>
</div>
</div>
</div>
<div class="wrapper">
<div class="col-wrap margin-bottom--4">
<div class="col col--lg-two-thirds col--md-two-thirds">
<div class="font-size--16 margin-top--4">
{{ localise "FeedbackFinished" $Language 1 .Metadata.Description .Metadata.Description | safeHTML }}
</div>
</div>
</div>
</div>
53 changes: 27 additions & 26 deletions assets/templates/feedback.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{$Language := .Language}}
<div class="page-intro background--gallery">
<div class="feedback-page-intro background--gallery">
<div class="wrapper">
<div class="col-wrap">
<div class="col margin-top--1">
{{ template "partials/breadcrumb" . }}
<h1 class="page-intro__title margin-bottom--4">
<h1 class="feedback-thanks feedback-page-intro__title margin-bottom--4" aria-live="polite">
<strong>{{ localise "FeedbackTitle" $Language 1 $.Metadata.Title }}</strong>
</h1>
</div>
Expand All @@ -16,60 +16,60 @@
<div class="col col--lg-two-thirds col--md-two-thirds">
{{if eq .Metadata.Title "Feedback"}}
<div id="feedback-description">
<p class="font-size--18 margin-top--5 margin-bottom--0">{{ localise "FeedbackDesc" $Language 1}}</p>
<p class="font-size--18 margin-top--5">{{ localise "FeedbackDesc" $Language 1}}</p>
</div>
<div class="margin--top-4">
<form id="feedback-form-container" action="/feedback" method="post">
<form id="feedback-form-page-container" action="/feedback" method="post">
<input type="hidden" name="feedback-form-type" value="page">
<fieldset>
<legend><h2 class="margin-bottom--4 font-size--30"><strong>{{ localise "FeedbackTitleWhat" $Language 1 }}</strong></h2></legend>
<div class="margin-top--2 margin-bottom--4">
<div class="multiple-choice margin-top--1 padding-left--2">
<input type="radio" class="multiple-choice__input" id="whole-site" name="type" value="The whole website">
<label class="multiple-choice__label font-size--18 padding-left--1" for="whole-site">
<div class="feedback-multiple-choice margin-top--1 padding-left--2">
<input type="radio" class="feedback-multiple-choice__input" id="whole-site" name="type" value="The whole website">
<label class="feedback-multiple-choice__label font-size--18 padding-left--1" for="whole-site">
{{ localise "FeedbackWholeWebsite" $Language 1 }}
</label>
</div>
{{if .ServiceDescription}}
<div class="multiple-choice margin-top--1 padding-left--2">
<input type="radio" class="multiple-choice__input" id="new-service" name="type" value="The new service">
<label class="multiple-choice__label font-size--18 padding-left--1" for="new-service">
<div class="feedback-multiple-choice margin-top--1 padding-left--2">
<input type="radio" class="feedback-multiple-choice__input" id="new-service" name="type" value="The new service">
<label class="feedback-multiple-choice__label font-size--18 padding-left--1" for="new-service">
{{ localise "FeedbackWhatOptNewService" $Language 1 }}
&nbsp; &nbsp;<span class="form-helper">({{.ServiceDescription}})</span>
</label>
</div>
{{end}}
{{ if .PreviousURL }}
<div class="multiple-choice margin-top--1 padding-left--2">
<input type="radio" class="multiple-choice__input" id="specific-page" name="type" value="A specific page" checked>
<label class="multiple-choice__label font-size--18 " for="specific-page">
<div class="feedback-multiple-choice margin-top--1 padding-left--2">
<input type="radio" class="feedback-multiple-choice__input" id="specific-page" name="type" value="A specific page" checked>
<label class="feedback-multiple-choice__label font-size--18 " for="specific-page">
{{ localise "FeedbackWhatOptSpecificPage" $Language 1 }}
<input type="hidden" value="{{.PreviousURL}}" name="url">
</label>
<div class="multiple-choice__content height--0">
<div class="feedback-multiple-choice__content height--0">
<div class="margin-left--1">
<div class="clearfix">
<div class="col--sm-12 col--md-28 col--lg-36 margin-left--1">
<label class="font-size--18" for="page-url-field">{{ localise "FeedbackWhatEnterURL" $Language 1 }}</label>
<input type="url" id="page-url-field" value="{{.PreviousURL}}" class="form-control" name="url">
<input type="url" id="page-url-field" value="{{.PreviousURL}}" class="feedback-form-control" name="url">
</div>
</div>
</div>
</div>
</div>
{{ else }}
<div class="multiple-choice margin-top--1 padding-left--2">
<input type="radio" class="multiple-choice__input" id="specific-page" name="type" value="A specific page" checked>
<label class="multiple-choice__label font-size--18 padding-left--1" for="specific-page">
<div class="feedback-multiple-choice margin-top--1 padding-left--2">
<input type="radio" class="feedback-multiple-choice__input" id="specific-page" name="type" value="A specific page" checked>
<label class="feedback-multiple-choice__label font-size--18 padding-left--1" for="specific-page">
{{ localise "FeedbackASpecificPage" $Language 1 }}
<input type="hidden" value="{{.PreviousURL}}" name="url">
</label>
<div class="multiple-choice__content height--0">
<div class="feedback-multiple-choice__content height--0">
<div>
<div class="clearfix">
<div class="col--sm-12 col--md-28 col--lg-36 margin-left--1">
<label class="font-size--18" for="page-url-field">{{ localise "FeedbackWhatEnterURL" $Language 1 }}</label>
<input type="url" id="page-url-field" class="form-control" name="url">
<input type="url" id="page-url-field" class="feedback-form-control" name="url">
</div>
</div>
</div>
Expand All @@ -78,13 +78,13 @@
{{ end }}
</div>
</fieldset>
<div>
<div id="feedback-description-field">
<label id="description-field-label" for="description-field">
<h2 class="margin-top--0 margin-bottom--4 font-size--30"><strong>{{ localise "FeedbackTitleEntry" $Language 1 }}</strong></h2>
<span class="font-size--18 margin-bottom--3">{{ localise "FeedbackHintEntry" $Language 1 }}</span>
</label>
{{if eq .ErrorType "description"}}<span class="form-error">{{ localise "FeedbackAlertEntry" $Language 1 }}</span>{{end}}
<textarea id="description-field" class="form-control {{if eq .ErrorType "description"}}form-control__error{{end}}" name="description" rows="5">{{.Feedback}}</textarea>
<textarea id="description-field" class="feedback-form-control {{if eq .ErrorType "description"}}feedback-form-control__error{{end}}" name="description" rows="5">{{.Feedback}}</textarea>
</div>
<section>
<fieldset id="reply-request">
Expand All @@ -95,17 +95,17 @@
<label id="name-field-label" for="name-field">
<strong><span class="font-size--18">{{ localise "FeedbackTitleName" $Language 1 }}</span></strong>
</label>
<input id="name-field" class="form-control" type="text" name="name" value={{.Name}}>
<input id="name-field" class="feedback-form-control" type="text" name="name" value={{.Name}}>
<label id="email-field-label" for="email-field">
<strong><span class="font-size--18">{{ localise "FeedbackTitleEmail" $Language 1 }}</span></strong>
</label>
{{if eq .ErrorType "email"}}<span class="form-error">{{ localise "FeedbackAlertEmail" $Language 1 }}</span>{{end}}
<input id="email-field" class="form-control {{if eq .ErrorType "email"}}form-control__error{{end}}" type="text" name="email" value={{.Email}}>
<input id="email-field" class="feedback-form-control {{if eq .ErrorType "email"}}feedback-form-control__error{{end}}" type="text" name="email" value={{.Email}}>
<div class="font-size--18 form-helper margin-bottom--4">{{ localise "FeedbackReplyDisclaimer" $Language 1 }}</div>
</fieldset>
</section>
<div>
<input class="btn btn--primary font-weight-700 font-size--18" type="submit" value="{{ localise "FeedbackSubmit" $Language 1 }}">
<input class="feedback-btn btn btn--primary font-weight-700 font-size--18" type="submit" value="{{ localise "FeedbackSubmit" $Language 1 }}">
</div>
</form>
</div>
Expand All @@ -116,4 +116,5 @@
{{end}}
</div>
</div>
</div>
</div>

2 changes: 1 addition & 1 deletion ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ image_resource:
type: docker-image
source:
repository: golang
tag: 1.15.8
tag: 1.18.6

inputs:
- name: dp-frontend-feedback-controller
Expand Down
2 changes: 1 addition & 1 deletion ci/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ image_resource:
type: docker-image
source:
repository: golang
tag: 1.15.8
tag: 1.18.6

inputs:
- name: dp-frontend-feedback-controller
Expand Down
10 changes: 5 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ var cfg *Config
// Get returns the default config with any modifications through environment
// variables
func Get() (*Config, error) {
cfg, err := get()
envCfg, err := get()
if err != nil {
return nil, err
}

if cfg.Debug {
cfg.PatternLibraryAssetsPath = "http://localhost:9000/dist"
if envCfg.Debug {
envCfg.PatternLibraryAssetsPath = "http://localhost:9002/dist/assets"
} else {
cfg.PatternLibraryAssetsPath = "//cdn.ons.gov.uk/sixteens/67f6982"
envCfg.PatternLibraryAssetsPath = "//cdn.ons.gov.uk/dp-design-system/2bd1840"
}
return cfg, nil
return envCfg, nil
}

func get() (*Config, error) {
Expand Down
3 changes: 0 additions & 3 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ import (
func TestConfig(t *testing.T) {
Convey("Given an environment with no environment variables set", t, func() {
cfg, err := Get()

Convey("When the config values are retrieved", func() {

Convey("Then there should be no error returned", func() {
So(err, ShouldBeNil)
})

Convey("Then the values should be set to the expected defaults", func() {
So(cfg.GracefulShutdownTimeout, ShouldEqual, 5*time.Second)
So(cfg.HealthCheckInterval, ShouldEqual, 30*time.Second)
Expand Down
6 changes: 3 additions & 3 deletions email/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ type SMTPSender struct {
Auth smtp.Auth
}

func (S SMTPSender) Send(from string, to []string, msg []byte) error {
func (s SMTPSender) Send(from string, to []string, msg []byte) error {
return smtp.SendMail(
S.Addr,
S.Auth,
s.Addr,
s.Auth,
from,
to,
msg)
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@ go 1.18
require (
github.com/ONSdigital/dp-frontend-models v1.10.1
github.com/ONSdigital/dp-healthcheck v1.1.0
github.com/ONSdigital/dp-net v1.2.0
github.com/ONSdigital/dp-renderer v1.38.1
github.com/ONSdigital/dp-net v1.4.1
github.com/ONSdigital/dp-renderer v1.49.0
github.com/ONSdigital/go-ns v0.0.0-20210831102424-ebdecc20fe9e
github.com/ONSdigital/log.go/v2 v2.0.9
github.com/gorilla/mux v1.8.0
github.com/gorilla/schema v1.2.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/smartystreets/goconvey v1.6.4
github.com/smartystreets/goconvey v1.7.2
)

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/ONSdigital/dp-api-clients-go v1.43.0 // indirect
github.com/aws/aws-sdk-go v1.38.15 // indirect
github.com/c2h5oh/datasize v0.0.0-20200825124411-48ed595a09d2 // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gopherjs/gopherjs v0.0.0-20210202160940-bed99a852dfe // indirect
github.com/gosimple/slug v1.9.0 // indirect
github.com/hokaccha/go-prettyjson v0.0.0-20210113012101-fb4e108d2519 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/justinas/alice v1.2.0 // indirect
github.com/kevinburke/go-bindata v3.23.0+incompatible // indirect
github.com/kevinburke/go-bindata v3.24.0+incompatible // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/nicksnyder/go-i18n/v2 v2.1.2 // indirect
Expand Down
Loading

0 comments on commit df0c1b5

Please sign in to comment.