This fixes a part of staticcheck issues and updates the code of conduct

Update example for set cell hyperlinks with `HyperlinkOpts`
This commit is contained in:
xuri 2022-05-18 23:15:24 +08:00
parent be5a4033c0
commit 8f16a76781
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
7 changed files with 79 additions and 75 deletions

View File

@ -2,45 +2,76 @@
## Our Pledge ## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
## Our Standards ## Our Standards
Examples of behavior that contributes to creating a positive environment include: Examples of behavior that contributes to a positive environment for our community include:
* Using welcoming and inclusive language * Demonstrating empathy and kindness toward other people
* Being respectful of differing viewpoints and experiences * Being respectful of differing opinions, viewpoints, and experiences
* Gracefully accepting constructive criticism * Giving and gracefully accepting constructive feedback
* Focusing on what is best for the community * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Showing empathy towards other community members * Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior by participants include: Examples of unacceptable behavior include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances * The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting/derogatory comments, and personal or political attacks * Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment * Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission * 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 * Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities ## Enforcement Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
## Scope ## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
## Enforcement ## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [xuri.me](https://xuri.me). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [xuri.me](https://xuri.me). All complaints will be reviewed and investigated promptly and fairly.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. All community leaders are obligated to respect the privacy and security of the reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
### 2. Warning
Community Impact: A violation through a single incident or series of actions.
Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
### 3. Temporary Ban
Community Impact: A serious violation of community standards, including sustained inappropriate behavior.
Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
Consequence: A permanent ban from any sort of public interaction within the community.
## Attribution ## 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][version] This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
[homepage]: https://www.contributor-covenant.org Community Impact Guidelines were inspired by Mozillas code of conduct enforcement ladder.
[version]: https://www.contributor-covenant.org/version/2/0/code_of_conduct
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations).

View File

@ -191,20 +191,18 @@ indicate acceptance.
The sign-off is a simple line at the end of the explanation for the patch. Your The sign-off is a simple line at the end of the explanation for the patch. Your
signature certifies that you wrote the patch or otherwise have the right to pass signature certifies that you wrote the patch or otherwise have the right to pass
it on as an open-source patch. The rules are pretty simple: if you can certify it on as an open-source patch. The rules are pretty simple: if you can certify
the below (from [developercertificate.org](http://developercertificate.org/)): the below (from [developercertificate.org](https://developercertificate.org)):
```text ```text
Developer Certificate of Origin Developer Certificate of Origin
Version 1.1 Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors. Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed. license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1 Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that: By making a contribution to this project, I certify that:
@ -347,9 +345,9 @@ The rules:
1. All code should be formatted with `gofmt -s`. 1. All code should be formatted with `gofmt -s`.
2. All code should pass the default levels of 2. All code should pass the default levels of
[`golint`](https://github.com/golang/lint). [`go vet`](https://pkg.go.dev/cmd/vet).
3. All code should follow the guidelines covered in [Effective 3. All code should follow the guidelines covered in [Effective
Go](http://golang.org/doc/effective_go.html) and [Go Code Review Go](https://go.dev/doc/effective_go) and [Go Code Review
Comments](https://github.com/golang/go/wiki/CodeReviewComments). Comments](https://github.com/golang/go/wiki/CodeReviewComments).
4. Comment the code. Tell us the why, the history and the context. 4. Comment the code. Tell us the why, the history and the context.
5. Document _all_ declarations and methods, even private ones. Declare 5. Document _all_ declarations and methods, even private ones. Declare
@ -372,13 +370,13 @@ The rules:
guidelines. Since you've read all the rules, you now know that. guidelines. Since you've read all the rules, you now know that.
If you are having trouble getting into the mood of idiomatic Go, we recommend If you are having trouble getting into the mood of idiomatic Go, we recommend
reading through [Effective Go](https://golang.org/doc/effective_go.html). The reading through [Effective Go](https://go.dev/doc/effective_go). The
[Go Blog](https://blog.golang.org) is also a great resource. Drinking the [Go Blog](https://go.dev/blog/) is also a great resource. Drinking the
kool-aid is a lot easier than going thirsty. kool-aid is a lot easier than going thirsty.
## Code Review Comments and Effective Go Guidelines ## Code Review Comments and Effective Go Guidelines
[CodeLingo](https://codelingo.io) automatically checks every pull request against the following guidelines from [Effective Go](https://golang.org/doc/effective_go.html) and [Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments). [CodeLingo](https://www.codelingo.io) automatically checks every pull request against the following guidelines from [Effective Go](https://go.dev/doc/effective_go) and [Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments).
### Package Comment ### Package Comment

33
calc.go
View File

@ -2512,31 +2512,23 @@ func convertTemperature(fromUOM, toUOM string, value float64) float64 {
switch fromUOM { switch fromUOM {
case "F": case "F":
value = (value-32)/1.8 + 273.15 value = (value-32)/1.8 + 273.15
break
case "C": case "C":
value += 273.15 value += 273.15
break
case "Rank": case "Rank":
value /= 1.8 value /= 1.8
break
case "Reau": case "Reau":
value = value*1.25 + 273.15 value = value*1.25 + 273.15
break
} }
// convert from Kelvin // convert from Kelvin
switch toUOM { switch toUOM {
case "F": case "F":
value = (value-273.15)*1.8 + 32 value = (value-273.15)*1.8 + 32
break
case "C": case "C":
value -= 273.15 value -= 273.15
break
case "Rank": case "Rank":
value *= 1.8 value *= 1.8
break
case "Reau": case "Reau":
value = (value - 273.15) * 0.8 value = (value - 273.15) * 0.8
break
} }
return value return value
} }
@ -2567,8 +2559,8 @@ func (fn *formulaFuncs) CONVERT(argsList *list.List) formulaArg {
} else if fromCategory == catgoryTemperature { } else if fromCategory == catgoryTemperature {
return newNumberFormulaArg(convertTemperature(fromUOM, toUOM, val)) return newNumberFormulaArg(convertTemperature(fromUOM, toUOM, val))
} }
fromConversion, _ := unitConversions[fromCategory][fromUOM] fromConversion := unitConversions[fromCategory][fromUOM]
toConversion, _ := unitConversions[fromCategory][toUOM] toConversion := unitConversions[fromCategory][toUOM]
baseValue := val * (1 / fromConversion) baseValue := val * (1 / fromConversion)
return newNumberFormulaArg((baseValue * toConversion) / toMultiplier) return newNumberFormulaArg((baseValue * toConversion) / toMultiplier)
} }
@ -4617,9 +4609,7 @@ func cofactorMatrix(i, j int, A [][]float64) float64 {
sign = 1 sign = 1
} }
var B [][]float64 var B [][]float64
for _, row := range A { B = append(B, A...)
B = append(B, row)
}
for m := 0; m < N; m++ { for m := 0; m < N; m++ {
for n := j + 1; n < N; n++ { for n := j + 1; n < N; n++ {
B[m][n-1] = B[m][n] B[m][n-1] = B[m][n]
@ -8317,7 +8307,6 @@ func calcColumnMeans(mtxX, mtxRes [][]float64, c, r int) {
} }
putDouble(mtxRes, i, sum/float64(r)) putDouble(mtxRes, i, sum/float64(r))
} }
return
} }
// calcColumnsDelta calculates subtract of the columns of matrix. // calcColumnsDelta calculates subtract of the columns of matrix.
@ -8688,10 +8677,8 @@ func calcTrendGrowthRegression(bConstant, bGrowth bool, trendType, nCXN, nRXN, K
switch trendType { switch trendType {
case 1: case 1:
calcTrendGrowthSimpleRegression(bConstant, bGrowth, mtxY, mtxX, newX, mtxRes, meanY, N) calcTrendGrowthSimpleRegression(bConstant, bGrowth, mtxY, mtxX, newX, mtxRes, meanY, N)
break
case 2: case 2:
calcTrendGrowthMultipleRegressionPart1(bConstant, bGrowth, mtxY, mtxX, newX, mtxRes, meanY, nRXN, K, N) calcTrendGrowthMultipleRegressionPart1(bConstant, bGrowth, mtxY, mtxX, newX, mtxRes, meanY, nRXN, K, N)
break
default: default:
calcTrendGrowthMultipleRegressionPart2(bConstant, bGrowth, mtxY, mtxX, newX, mtxRes, meanY, nCXN, K, N) calcTrendGrowthMultipleRegressionPart2(bConstant, bGrowth, mtxY, mtxX, newX, mtxRes, meanY, nCXN, K, N)
} }
@ -8728,10 +8715,8 @@ func calcTrendGrowth(mtxY, mtxX, newX [][]float64, bConstant, bGrowth bool) ([][
switch trendType { switch trendType {
case 1: case 1:
mtxRes = getNewMatrix(nCXN, nRXN) mtxRes = getNewMatrix(nCXN, nRXN)
break
case 2: case 2:
mtxRes = getNewMatrix(1, nRXN) mtxRes = getNewMatrix(1, nRXN)
break
default: default:
mtxRes = getNewMatrix(nCXN, 1) mtxRes = getNewMatrix(nCXN, 1)
} }
@ -10630,13 +10615,10 @@ func getTDist(T, fDF, nType float64) float64 {
switch nType { switch nType {
case 1: case 1:
res = 0.5 * getBetaDist(fDF/(fDF+T*T), fDF/2, 0.5) res = 0.5 * getBetaDist(fDF/(fDF+T*T), fDF/2, 0.5)
break
case 2: case 2:
res = getBetaDist(fDF/(fDF+T*T), fDF/2, 0.5) res = getBetaDist(fDF/(fDF+T*T), fDF/2, 0.5)
break
case 3: case 3:
res = math.Pow(1+(T*T/fDF), -(fDF+1)/2) / (math.Sqrt(fDF) * getBeta(0.5, fDF/2.0)) res = math.Pow(1+(T*T/fDF), -(fDF+1)/2) / (math.Sqrt(fDF) * getBeta(0.5, fDF/2.0))
break
case 4: case 4:
X := fDF / (T*T + fDF) X := fDF / (T*T + fDF)
R := 0.5 * getBetaDist(X, 0.5*fDF, 0.5) R := 0.5 * getBetaDist(X, 0.5*fDF, 0.5)
@ -10644,7 +10626,6 @@ func getTDist(T, fDF, nType float64) float64 {
if T < 0 { if T < 0 {
res = R res = R
} }
break
} }
return res return res
} }
@ -10888,15 +10869,11 @@ func tTest(bTemplin bool, mtx1, mtx2 [][]formulaArg, c1, c2, r1, r2 int, fT, fF
return 0, 0, false return 0, 0, false
} }
c := fS1 / (fS1 + fS2) c := fS1 / (fS1 + fS2)
fT = math.Abs(sum1/cnt1-sum2/cnt2) / math.Sqrt(fS1+fS2) return math.Abs(sum1/cnt1-sum2/cnt2) / math.Sqrt(fS1+fS2), 1 / (c*c/(cnt1-1) + (1-c)*(1-c)/(cnt2-1)), true
fF = 1 / (c*c/(cnt1-1) + (1-c)*(1-c)/(cnt2-1))
return fT, fF, true
} }
fS1 := (sumSqr1 - sum1*sum1/cnt1) / (cnt1 - 1) fS1 := (sumSqr1 - sum1*sum1/cnt1) / (cnt1 - 1)
fS2 := (sumSqr2 - sum2*sum2/cnt2) / (cnt2 - 1) fS2 := (sumSqr2 - sum2*sum2/cnt2) / (cnt2 - 1)
fT = math.Abs(sum1/cnt1-sum2/cnt2) / math.Sqrt((cnt1-1)*fS1+(cnt2-1)*fS2) * math.Sqrt(cnt1*cnt2*(cnt1+cnt2-2)/(cnt1+cnt2)) return math.Abs(sum1/cnt1-sum2/cnt2) / math.Sqrt((cnt1-1)*fS1+(cnt2-1)*fS2) * math.Sqrt(cnt1*cnt2*(cnt1+cnt2-2)/(cnt1+cnt2)), cnt1 + cnt2 - 2, true
fF = cnt1 + cnt2 - 2
return fT, fF, true
} }
// tTest is an implementation of the formula function TTEST. // tTest is an implementation of the formula function TTEST.

View File

@ -686,8 +686,12 @@ type HyperlinkOpts struct {
// the other functions such as `SetCellStyle` or `SetSheetRow`. The below is // the other functions such as `SetCellStyle` or `SetSheetRow`. The below is
// example for external link. // example for external link.
// //
// display, tooltip := "https://github.com/xuri/excelize", "Excelize on GitHub"
// if err := f.SetCellHyperLink("Sheet1", "A3", // if err := f.SetCellHyperLink("Sheet1", "A3",
// "https://github.com/xuri/excelize", "External"); err != nil { // "https://github.com/xuri/excelize", "External", excelize.HyperlinkOpts{
// Display: &display,
// Tooltip: &tooltip,
// }); err != nil {
// fmt.Println(err) // fmt.Println(err)
// } // }
// // Set underline and font color style for the cell. // // Set underline and font color style for the cell.

View File

@ -36,7 +36,7 @@ type numberFormat struct {
sectionIdx int sectionIdx int
date1904, isNumeric, hours, seconds bool date1904, isNumeric, hours, seconds bool
number float64 number float64
ap, afterPoint, beforePoint, localCode, result, value, valueSectionType string ap, localCode, result, value, valueSectionType string
} }
var ( var (

View File

@ -371,10 +371,8 @@ func (f *File) setContentTypePartImageExtensions() {
content.Lock() content.Lock()
defer content.Unlock() defer content.Unlock()
for _, file := range content.Defaults { for _, file := range content.Defaults {
if _, ok := imageTypes[file.Extension]; ok {
delete(imageTypes, file.Extension) delete(imageTypes, file.Extension)
} }
}
for extension, prefix := range imageTypes { for extension, prefix := range imageTypes {
content.Defaults = append(content.Defaults, xlsxDefault{ content.Defaults = append(content.Defaults, xlsxDefault{
Extension: extension, Extension: extension,

View File

@ -874,11 +874,9 @@ func formatToA(v, format string, date1904 bool) string {
return v return v
} }
if f < 0 { if f < 0 {
t := int(math.Abs(f)) return fmt.Sprintf("(%d)", int(math.Abs(f)))
return fmt.Sprintf("(%d)", t)
} }
t := int(f) return fmt.Sprintf("%d", int(f))
return fmt.Sprintf("%d", t)
} }
// formatToB provides a function to convert original string to special format // formatToB provides a function to convert original string to special format
@ -901,8 +899,7 @@ func formatToC(v, format string, date1904 bool) string {
if err != nil { if err != nil {
return v return v
} }
f *= 100 return fmt.Sprintf("%.f%%", f*100)
return fmt.Sprintf("%.f%%", f)
} }
// formatToD provides a function to convert original string to special format // formatToD provides a function to convert original string to special format
@ -912,8 +909,7 @@ func formatToD(v, format string, date1904 bool) string {
if err != nil { if err != nil {
return v return v
} }
f *= 100 return fmt.Sprintf("%.2f%%", f*100)
return fmt.Sprintf("%.2f%%", f)
} }
// formatToE provides a function to convert original string to special format // formatToE provides a function to convert original string to special format