Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Resolves #92, Identifier Name Violation Issues after updating to Xcode 9.3 #93

Merged
merged 6 commits into from
May 12, 2018

Conversation

antsangrigoli
Copy link

PR Description

This is in response to issue #92. When building the project in Xcode 9.3, I was getting 9 Identifier Name Violations errors. I've fixed these errors by adding // swiftlint:disable:next identifier_name as you can see in the screenshots below. Project can now be built and ran in Xcode 9.3.

Type of Changes

Screenshots

Before

screen shot 2018-04-28 at 4 40 48 pm
screen shot 2018-04-28 at 4 40 59 pm

After

screen shot 2018-05-04 at 3 07 19 pm
screen shot 2018-05-04 at 3 06 44 pm

Checklist

Make sure you've done all the following (Put an x in the boxes that apply.)

  • If you have multiple commits please combine them into one commit by squashing them.
  • Code is well documented
  • Included unit tests for new functionality
  • All user-visible strings are made translatable
  • Code passes Travis builds in your branch

@@ -32,6 +32,7 @@ class SettingsTableViewController: UITableViewController, MFMailComposeViewContr
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
// swiftlint:disable:next identifier_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, instead of disabling swiftlint here, the 'Settings' variable should be 'settings' variable.

Copy link
Author

@antsangrigoli antsangrigoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed variable Settings to settings

@rudrankriyam
Copy link
Contributor

rudrankriyam commented May 4, 2018

I had two solution for this -

  1. Either add swiftlint disable rule, or
  2. Change the name of the variable.

Like, there are many warnings due to 'vc' variable, referring to ViewControllers. We can rename them to SummaryFormTableVC or NutritionTableFormVC etc

What do you propose @antsangrigoli @roger-tan ?

@@ -19,10 +19,12 @@ extension UIColor {

var rgb: UInt32 = 0

// swiftlint:disable identifier_name
var r: CGFloat = 0.0
Copy link
Contributor

@roger-tan roger-tan May 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I'm not a huge fan of abbreviation. Instead to disable the error. We should just rename r as red, green as green, b as blue and a as alpha. This will make the code understandable without guessing each abbreviation what does it means.

Copy link
Author

@antsangrigoli antsangrigoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Renamed variables r to red, g to green, b to blue, a to alpha in UIColor.swift

@snuff4 @roger-tan
The only other warnings I can see about an Identifier Name Violation are for the variables "id" and "vc".
As snuff4 mentioned, I'm going to rename each "vc" variable to its specific view controller name

Copy link
Author

@antsangrigoli antsangrigoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed each "vc" variable to its specific view controller name

@aleene
Copy link
Collaborator

aleene commented May 5, 2018

I concur. I prefer large variable names as well, so it is clear what a variable represents.

By the way, if I have an optional, which I unwrap with guard or let, I start the new variable with validVariable, so I know the original was an optional.

@@ -31,28 +31,28 @@ class UserViewController: UIViewController, DataManagerClient {
showProductsPendingUpload()
}

vc = childNavigationController
UIVC = childNavigationController

Copy link
Contributor

@rudrankriyam rudrankriyam May 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change it to childNavigationVC? And we need to make sure every function of the app is working, after the changes

Copy link
Author

@antsangrigoli antsangrigoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed "UIVC" to childNavigationVC

@rudrankriyam
Copy link
Contributor

@antsangrigoli can you ensure that everything is working after renaming?

@antsangrigoli
Copy link
Author

@snuff4 yes everything seems to work fine.
However, I'm getting warnings on the variable 'id'. You think I should add the swiftlint disable rule or rename 'id' ?

@rudrankriyam
Copy link
Contributor

@antsangrigoli
Copy link
Author

@snuff4 Just read up on it. I could add the following parameters below to the .swiftlint.yml file and this will solve the issue.

identifier_name:
excluded:
- id

@rudrankriyam
Copy link
Contributor

poke @roger-tan For this I think we can exclude for this. We need to finish with this PR asap, because without it, it's not working on 9.3

@@ -29,8 +29,8 @@ extension UIViewController {
}

func openUrlInApp(_ url: URL, showAlert: Bool? = nil) {
let vc = SFSafariViewController(url: url, entersReaderIfAvailable: false)
present(vc, animated: true)
let SFSafariVC = SFSafariViewController(url: url, entersReaderIfAvailable: false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally for local context. I would just call controller but a variable name cannot with an uppercase letter. We should keep the camel case for a name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I should rename the variable SFSafariVC to sfSafariVC ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep consistence inside the projet. Just sfSafariVC.

@roger-tan
Copy link
Contributor

For id. It's ok for me.

Copy link
Author

@antsangrigoli antsangrigoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Renamed SFSafariVC to sfSafariVC
  • Added parameter in .swiftlint.yml file to exclude variable name "id"

@roger-tan
Copy link
Contributor

@antsangrigoli Thank you for your contributions into OpenFoodFacts. Your Pull Request is now merged .

@roger-tan roger-tan merged commit 0aff145 into openfoodfacts:master May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants