diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 572b5612..5c400f8b 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,45 +2,76 @@ ## 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 -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 -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* 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 -* Trolling, insulting/derogatory comments, and personal or political attacks +* 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 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 -## 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 -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 -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 -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 -[version]: https://www.contributor-covenant.org/version/2/0/code_of_conduct +Community Impact Guidelines were inspired by Mozilla’s code of conduct enforcement ladder. + +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). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89bc60ed..847e3ac6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -191,20 +191,18 @@ indicate acceptance. 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 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 Developer Certificate of Origin Version 1.1 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 license document, but changing it is not allowed. + Developer's Certificate of Origin 1.1 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`. 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 - 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). 4. Comment the code. Tell us the why, the history and the context. 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. 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 -[Go Blog](https://blog.golang.org) is also a great resource. Drinking the +reading through [Effective Go](https://go.dev/doc/effective_go). The +[Go Blog](https://go.dev/blog/) is also a great resource. Drinking the kool-aid is a lot easier than going thirsty. ## 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 diff --git a/calc.go b/calc.go index 16d183b6..f71f3e81 100644 --- a/calc.go +++ b/calc.go @@ -2512,31 +2512,23 @@ func convertTemperature(fromUOM, toUOM string, value float64) float64 { switch fromUOM { case "F": value = (value-32)/1.8 + 273.15 - break case "C": value += 273.15 - break case "Rank": value /= 1.8 - break case "Reau": value = value*1.25 + 273.15 - break } // convert from Kelvin switch toUOM { case "F": value = (value-273.15)*1.8 + 32 - break case "C": value -= 273.15 - break case "Rank": value *= 1.8 - break case "Reau": value = (value - 273.15) * 0.8 - break } return value } @@ -2567,8 +2559,8 @@ func (fn *formulaFuncs) CONVERT(argsList *list.List) formulaArg { } else if fromCategory == catgoryTemperature { return newNumberFormulaArg(convertTemperature(fromUOM, toUOM, val)) } - fromConversion, _ := unitConversions[fromCategory][fromUOM] - toConversion, _ := unitConversions[fromCategory][toUOM] + fromConversion := unitConversions[fromCategory][fromUOM] + toConversion := unitConversions[fromCategory][toUOM] baseValue := val * (1 / fromConversion) return newNumberFormulaArg((baseValue * toConversion) / toMultiplier) } @@ -4617,9 +4609,7 @@ func cofactorMatrix(i, j int, A [][]float64) float64 { sign = 1 } var B [][]float64 - for _, row := range A { - B = append(B, row) - } + B = append(B, A...) for m := 0; m < N; m++ { for n := j + 1; n < N; 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)) } - return } // calcColumnsDelta calculates subtract of the columns of matrix. @@ -8688,10 +8677,8 @@ func calcTrendGrowthRegression(bConstant, bGrowth bool, trendType, nCXN, nRXN, K switch trendType { case 1: calcTrendGrowthSimpleRegression(bConstant, bGrowth, mtxY, mtxX, newX, mtxRes, meanY, N) - break case 2: calcTrendGrowthMultipleRegressionPart1(bConstant, bGrowth, mtxY, mtxX, newX, mtxRes, meanY, nRXN, K, N) - break default: 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 { case 1: mtxRes = getNewMatrix(nCXN, nRXN) - break case 2: mtxRes = getNewMatrix(1, nRXN) - break default: mtxRes = getNewMatrix(nCXN, 1) } @@ -10630,13 +10615,10 @@ func getTDist(T, fDF, nType float64) float64 { switch nType { case 1: res = 0.5 * getBetaDist(fDF/(fDF+T*T), fDF/2, 0.5) - break case 2: res = getBetaDist(fDF/(fDF+T*T), fDF/2, 0.5) - break case 3: res = math.Pow(1+(T*T/fDF), -(fDF+1)/2) / (math.Sqrt(fDF) * getBeta(0.5, fDF/2.0)) - break case 4: X := fDF / (T*T + fDF) R := 0.5 * getBetaDist(X, 0.5*fDF, 0.5) @@ -10644,7 +10626,6 @@ func getTDist(T, fDF, nType float64) float64 { if T < 0 { res = R } - break } return res } @@ -10888,15 +10869,11 @@ func tTest(bTemplin bool, mtx1, mtx2 [][]formulaArg, c1, c2, r1, r2 int, fT, fF return 0, 0, false } c := fS1 / (fS1 + fS2) - fT = math.Abs(sum1/cnt1-sum2/cnt2) / math.Sqrt(fS1+fS2) - fF = 1 / (c*c/(cnt1-1) + (1-c)*(1-c)/(cnt2-1)) - return fT, fF, true + return math.Abs(sum1/cnt1-sum2/cnt2) / math.Sqrt(fS1+fS2), 1 / (c*c/(cnt1-1) + (1-c)*(1-c)/(cnt2-1)), true } fS1 := (sumSqr1 - sum1*sum1/cnt1) / (cnt1 - 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)) - fF = cnt1 + cnt2 - 2 - return fT, fF, true + 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 } // tTest is an implementation of the formula function TTEST. diff --git a/cell.go b/cell.go index 1e130dcb..a3020177 100644 --- a/cell.go +++ b/cell.go @@ -686,8 +686,12 @@ type HyperlinkOpts struct { // the other functions such as `SetCellStyle` or `SetSheetRow`. The below is // example for external link. // +// display, tooltip := "https://github.com/xuri/excelize", "Excelize on GitHub" // 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) // } // // Set underline and font color style for the cell. diff --git a/numfmt.go b/numfmt.go index 2052fd9b..6b4fc653 100644 --- a/numfmt.go +++ b/numfmt.go @@ -31,12 +31,12 @@ type languageInfo struct { // numberFormat directly maps the number format parser runtime required // fields. type numberFormat struct { - section []nfp.Section - t time.Time - sectionIdx int - date1904, isNumeric, hours, seconds bool - number float64 - ap, afterPoint, beforePoint, localCode, result, value, valueSectionType string + section []nfp.Section + t time.Time + sectionIdx int + date1904, isNumeric, hours, seconds bool + number float64 + ap, localCode, result, value, valueSectionType string } var ( diff --git a/picture.go b/picture.go index 8e2fa12f..30a66d36 100644 --- a/picture.go +++ b/picture.go @@ -371,9 +371,7 @@ func (f *File) setContentTypePartImageExtensions() { content.Lock() defer content.Unlock() for _, file := range content.Defaults { - if _, ok := imageTypes[file.Extension]; ok { - delete(imageTypes, file.Extension) - } + delete(imageTypes, file.Extension) } for extension, prefix := range imageTypes { content.Defaults = append(content.Defaults, xlsxDefault{ diff --git a/styles.go b/styles.go index b7b1525d..4b5c7727 100644 --- a/styles.go +++ b/styles.go @@ -874,11 +874,9 @@ func formatToA(v, format string, date1904 bool) string { return v } if f < 0 { - t := int(math.Abs(f)) - return fmt.Sprintf("(%d)", t) + return fmt.Sprintf("(%d)", int(math.Abs(f))) } - t := int(f) - return fmt.Sprintf("%d", t) + return fmt.Sprintf("%d", int(f)) } // 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 { return v } - f *= 100 - return fmt.Sprintf("%.f%%", f) + return fmt.Sprintf("%.f%%", f*100) } // 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 { return v } - f *= 100 - return fmt.Sprintf("%.2f%%", f) + return fmt.Sprintf("%.2f%%", f*100) } // formatToE provides a function to convert original string to special format